Professional Documents
Culture Documents
AWS ECS, EKS - : Principle Enterprise Evangelist @
AWS ECS, EKS - : Principle Enterprise Evangelist @
2019.11.27
컨테이너가 대세라고 하는데 …
오케스트레이션 ?
컨테이너 ?
쿠버네티스 ?
AWS에서
컨테이너 활용하기
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
2
다양한 AWS의 컨테이너 서비스
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
3
TODAY’S QUEST
❖ 컨테이너 및 쿠버네티스 개요
❖ Amazon EKS
❖ Amazon ECS
❖ AWS Fargate
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
일반적인 어플리케이션의 구성
런 타임 엔진 코드
디펜던시 구성
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
5
각기 다른 서버 환경이 갖고 있는 문제점
• 수많은 애플리케이션 스택
• 각기 다른 하드웨어 배포 환경
다른 환경으로 쉽게
마이그레이션하고 실행하는 방법?
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
6
솔루션, 컨테이너
효율성 : OS kernel 공유
이식성 : 이미지 기반 배포
유연성 : 마이크로 서비스 모듈화
신속성 : 가벼운 도커 이미지
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
7
클라우드 시대 이미 VM으로 충분하지 않을까 ?
Container
App 2App 1
VM App 2 App 3
Hypervisor Hypervisor
Host OS Host OS
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
8
늘어나는 컨테이너를 어떻게 관리할까? → 컨테이너 오케스트레이션의 필요
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
9
컨테이너 오케스트레이션(Orchestration)
myGameJob: {
Cpu: 10
Mem: 256 오케스트레이터
}
스케쥴링
“myGameJob”을 실행해 줘
“myGameJob”을 3개 확실히 실행해 줘
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
10
쿠버네티스 이해 - 파드(Pods)
파드 내 공유자원:
IP
• 저장소
Container A
• 네트워크 주소
Container B
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
11
쿠버네티스 이해 - 디플로이먼트(Deployments)
• 파드의 개수를 보장
• 파드의 위치를 자동으로 결정
• 개선 사항이 있을 경우 자동 업데이트
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
12
쿠버네티스 이해 - 서비스(Services)
IP
IP
IP Service
IP
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
13
쿠버네티스 이해 - N개의 컨테이너를 띄운다면
디플로이먼트를 정의하고
리플리카(replicas)를 3으로 설정 Host 1
kubectl deployment
Host 2
rep = 3
Host 3
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
14
쿠버네티스 이해 - 더 많은 성능을 필요로 할 때 : Scale Out
더 많은 컨테이너가 필요하면
리플리카셋을 업데이트 Host 1
kubectl deployment
Host 2
rep = 5
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
15
쿠버네티스 이해 - 비정상 종료 상황 발생 시
Host 1
kubectl deployment
Host 2
rep = 5
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
16
TODAY’S QUEST
❖ 컨테이너 및 쿠버네티스 개요
❖ Amazon EKS
❖ Amazon ECS
❖ AWS Fargate
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
쿠버네티스가 가장 많이 실행되는 클라우드는 ?
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
18
Kubernetes on AWS – Amazon EKS(Elastic Kubernetes Service)
Master
Etcd
관리형 자동 버전 다른 AWS
높은 가용성
관리형 쿠버네티스 컨트롤 플레인 업데이트 서비스와 연동
CloudTrail,
CloudWatch, ELB,
IAM, VPC, PrivateLink
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
19
EKS 아키텍처
Kubectl mycluster.eks.amazonaws.com
AZ 1 AZ 2 AZ 3
EKS 워커 노드
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
21
마스터 노드 관리
AWS 관리 VPC
마스터 노드 마스터 노드 마스터 노드
고객 관리 VPC
워커 노드 워커 노드 워커 노드
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
22
IAM 인증
Kubectl
K8s API AWS Auth
4) K8s action
allowed/denied
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
23
EKS 버전 업데이트
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
24
EKS 최적화 AMI 제공
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
25
컨테이너 서비스 로드맵(EKS, ECS, Fargate)
https://github.com/aws/containers-roadmap
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
26
TODAY’S QUEST
❖ 컨테이너 및 쿠버네티스 개요
❖ Amazon EKS
❖ Amazon ECS
❖ AWS Fargate
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Amazon ECS(Elastic Container Service) 전체 구조
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK
ECS
Amazon ECS
AGENT
AGENT COMMUNICATION
Container Container SERVICE
API
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
28
Amazon ECS : 클러스터(Cluster)
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK
ECS
Amazon ECS
AGENT
AGENT COMMUNICATION
Container Container SERVICE
API
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
29
Amazon ECS : 작업(Task)
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK
ECS
Amazon ECS
AGENT
AGENT COMMUNICATION
Container Container SERVICE
API
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
30
Amazon ECS : 작업(Task)
scorekeep-api
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
31
Amazon ECS : 서비스(Service)
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK
ECS
Amazon ECS
AGENT
AGENT COMMUNICATION
Container Container SERVICE
API
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
32
Amazon ECS : 서비스(Service)
• 설정한 작업 수 자동 유지 및 복구
• 서비스 업데이트 시 blue/green 배포 가능
• ALB을 통해 효율적인 부하 분산
Application
• 서비스 오토스케일링 설정 가능 Load Balancing
작업
서비스
Service
서비스
오토스케일링
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
33
서비스 Blue/Green 배포
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
34
작업 배치 전략
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
35
작업 배치 전략
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
36
IAM Task Role(역할) – 필요한 권한만 부여
Identity
Amazon Access
ECS AWS IAM
Management
(IAM)
DynamoDBRole Amazon
DynamoDB
S3Role S3
IAM Task
ECS Task AWS IAM
Role
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
37
CloudWatch Logs에 작업 로그 저장
Stream
CloudWatch Logs Amazon Kinesis
Process
CloudWatch Logs AWS Lambda
Search
Amazon ElasticSearch
CloudWatch Logs
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
38
CloudWatch에서 사용 가능한 ECS 지표(Metrics)
CloudWatch CloudWatch
2 Dimensions EC2 Metrics ECS Metrics
• ClusterName Task
• ServiceName definition
Service
4 metrics
• CPUReservation Task
• MemoryReservation
• CPUUtilization
…
• MemoryUtilization
Cluster
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
39
(EC2 기반) ECS Cluster – Auto Scaling
New services
ECS
CloudWatch event
Developers
CloudWatch
ECS cluster
Event: Per cluster CPU, memory
reservation, or usage
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
40
서비스 – Auto Scaling
100% 30
90%
80% 25
CloudWatch
DesiredCount
70%
CPU
60% 20
50%
40% 15
30%
Amazon EC2 20% 10
10%
Service
0% 5
Traffic
Time
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
41
서비스 – Auto Scaling
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
42
TODAY’S QUEST
❖ 컨테이너 및 쿠버네티스 개요
❖ Amazon EKS
❖ Amazon ECS
❖ AWS Fargate
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
AWS Fargate
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
44
Amazon ECS
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
45
Amazon ECS powered by AWS Fargate
http://www.bespinglobal.com
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
46
Task의 CPU와 메모리 용량 범위
CPU와 메모리 기준 초당 과금 USD
용량 초 분 시간 하루 한달(30일)
총 50가지 유연한 구성 옵션 1 vCPU 0.00001406 0.0008 0.051 1.214784 36.44352
1 GB Mem0.00000353 0.0002 0.013 0.304992 9.14976
0.00001759 0.0011 0.063 1.519776 45.59328
CPU Memory
256 (.25 vCPU) 512MB, 1GB, 2GB
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
47
Fargate 작업 스토리지
10 GB per Task
휘발성 스토리지 제공
Writable Layer
Writable Layer
계층 스토리지(Layer Storage Space) :
• 10 GB의 Docker 계층 스토리지 Image Layers
Image Layers
Container 1 Container 2
Container 1 Container 2
볼륨 마운트를 위한 스토리지: /var/container1/data /var/container2/data
• 작업 당 4 GB 의 볼륨 스토리지 mount
• 작업 내 모든 컨테이너에서 공유 가능
4 GB Volume Storage
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
48
EC2와 Fargate의 하이브리드 구성도 가능
Amazon ECS CLUSTER
Web
FARGATE
Shopping
Cart
ECS Instance ECS Instance ECS Instance ECS Instance ECS Instance ECS Instance
Notifications
EC2
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
49
요약
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
50
Demo
5. 서비스 동작 확인
① 보안 그룹 확인, (ALB 이용 시) Target 그룹 확인
http://www.bespinglobal.com
Copyright © 2019 BESPIN GLOBAL, Inc. All rights reserved
51
THANK YOU