KEMBAR78
마이크로 서비스를 위한 AWS의 다양한 컨테이너 옵션 l 이창수 솔루션즈 아키텍트 | PDF
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
마이크로 서비스를 위한
AWS의 다양한 컨테이너 옵션
이창수, AWS 솔루션즈 아키텍트
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
목차
아마존 컨테이너 서비스
Amazon Elastic Container Service (ECS)
AWS Fargate
Amazon Elastic Container Service for Kubernetes (EKS)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
애플리케이션의 구성
런 타임 엔진 코드
디펜던시 구성
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
문제점
• 수많은 애플리케이션 스택
• 각기 다른 하드웨어 배포 환경
다른 환경으로 쉽게
마이그레이션하고 실행하는 방법?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
솔루션, 컨테이너
효율성 : OS kernel 공유
이식성 : 이미지 기반 배포
유연성 : 마이크로 서비스 모듈화
신속성 : 가벼운 도커 이미지
컨테이너는 코드, 런타임, 라이브러리,
패키지를 포함
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VM과 컨테이너 비교
Server (Host)
Host OS
Hypervisor
App 2
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1
App 2
App 3
VM
Server (Host)
Host OS
Docker
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
Container
Hypervisor
Guest OS
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
아마존 컨테이너 서비스
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
급속도로 증가하는 컨테이너 활용 규모
450+%
성장
수억개의 컨테이너
매주 새롭게 배포되는 컨테이너
수백만개의 인스턴스
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
멀티 컨테이너의 Orchestration은?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
다양한 아마존의 컨테이너 서비스
Management
스케쥴링, 스케일링,
배포 전략
Hosting
컨테이너가 수행되는 곳
Amazon
ECS
Amazon
EKS
Amazon
EC2
AWS
Fargate
Image Registry
컨테이너 이미지 저장소
Amazon
ECR
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
컨테이너 서비스 CI/CD 파이프 라인 통합
Amazon EC2
AWS
CodePipeline
Source Build Deploy
AWS
CodeCommit
AWS
CodeBuild
Amazon RDS
Amazon S3
Developer
Control plane
Data plane
Backing service
Registry
CI/CD pipeline
Amazon EFS
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
컨테이너 서비스 CI/CD 파이프 라인 통합
AWS
CodePipeline
AWS
CodeCommit
AWS
CodeBuild
Developer
Application
Load Balancer
Service
파이프 라인 생성 및 관리
코드 업 로드
이미지 확인 배포 후 상태 확인
registerTaskDefinition & updateService
docker build &
push
imageDefinition.json
source code
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS
(Elastic Container Service)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS
AWS VPC 네트워킹 모드
…{ }
고급 작업 배치
AWS 서비스 간편한 연동
명령줄 인터페이스
전세계 다양한 활용사례
강력한 스케줄링 기능
자동 확장
CloudWatch 매트릭
부하분산
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS 구성 요소 : 클러스터
Docker
Task
EC2 instance
Container
Docker
Task
EC2 instance
Task
Docker
EC2 instance
Task
AZ 1 AZ 2
Container Container Container
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS 구성 요소 : 클러스터 관리 엔진
Docker
EC2 instance
Docker
EC2 instance
Docker
EC2 instance
AZ 1 AZ 2
Cluster Management Engine
Container Container Container ContainerContainer Container
Task Task Task Task Task Task
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS 구성 요소 : ECS Agent
ECS agent
EC2 instance
ECS agent
Docker
EC2 instance
Docker
EC2 instance
Docker
AZ 1 AZ 2
Cluster Management Engine
Container Container Container ContainerContainer Container
Task Task Task Task Task Task
ECS agent
Agent Communication Service
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS 아키텍쳐
ALB ALB
AZ 1 AZ 2
user/scheduler
Scheduler
Cluster State Service
Placement Engine
Event Stream
Internet
ECS agent ECS agent ECS agent
EC2 instance EC2 instance EC2 instance
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS 구성 요소: 작업 (Task)
Data
Volume
Containers
Deploy
EC2
instance
Volume definitions
Container definitions
ECS 클러스터에서 배포되는 컨테이너의 최소 단위
작업 정의 내용을 기반으로 배포
한 작업 안의 컨테이너들은 모두 같은 호스트 EC2에 배포
{
"family": “scorekeep",
"containerDefinitions": [
{
"name":“scorekeep-frontend",
"image":"xxx.dkr.ecr.us-east-
1.amazonaws.com/fe"
},
{
"name":“scorekeep-api",
"image":"xxx.dkr.ecr.us-east-
1.amazonaws.com/api"
}
]
}
Task Definition – scorekeep:10
scorekeep-frontend
scorekeep-api
Task
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CloudWatch를 활용한 작업 log 수집 및 처리
CloudWatch Logs Amazon S3
Amazon Kinesis
AWS Lambda
Amazon ElasticSearch
Amazon ECS Store
Stream
Process
Search
CloudWatch Logs
CloudWatch Logs
CloudWatch Logs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IAM 작업 Role
AWS IAM
Amazon
DynamoDB
S3
AWS IAM
DynamoDBRole
S3Role
Amazon
ECS
IAM 작업
Role
Identity
Access
Management
(IAM)
ECS 작업
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS 구성 요소 : 서비스
• 설정한 작업 수 자동 유지 및 복구
• 서비스 업데이트 시 blue/green 배포 가능
• ALB을 통해 효율적인 부하 분산
• 서비스 오토스케일링 설정 가능
Service
Application
Load Balancing
서비스
오토스케일링
작업
서비스
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS : 서비스
◉ AWS 관리 콘솔  ECS  Clusters  Services  Create
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS : 서비스 blue/green
Task DesiredCount = 4, MinimumHealthyPercent = 100%, MaximumPercent =200%
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
작업 배치 전략
Binpacking Spread Affinity Distinct Instance
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
작업 배치 전략
◉ AWS management console  ECS  Clusters  Services  Create  Task Placement
Task  Run test  Task Placement
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CloudWatch ECS 메트릭
2개 차원
• ClusterName
• ServiceName
4개 메트릭
• CPUReservation
• MemoryReservation
• CPUUtilization
• MemoryUtilization
컨테이너
인스턴스
…
Cluster
작업 정의
작업
서비스
CloudWatch
ECS 메트릭
CloudWatch
EC2 메트릭
컨테이너
인스턴스
컨테이너
인스턴스
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
커스텀 메트릭
Mapbox는 31개 ECS 커스텀 메트릭 사용
• AgentConnectedPercent
• FailedTaskPlacement
• ActiveInstanceCount
• StatusCheckFailedInstances
• RunningTasksPerInstances
• Spot Termination
…
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECS 클러스터 오토 스케일 아웃
Event: Per 클러스터 CPU,메모리
reservation, utilization 혹은 커스텀 메트릭
새로운 서비스
Amazon
ECS
ECS 클러스터
CloudWatch
개발자
CloudWatch 이벤트
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECS 클러스터 오토 스케일 인
Draining
CloudWatch
Event: Per 클러스터 CPU,메모리
reservation, utilization 혹은 커스텀 메트릭
Amazon
ECS
ECS 클러스터
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service Auto Scaling
◉ AWS management console  ECS  Clusters  Services  Configure Service Auto Scaling
Amazon EC2
Service
Resource
buffer
(+~15%)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
측정 대상의 목표 값 설정하면 자동 조정
(예: CPU utilization 50%)
대상 추적을 통해 서비스의 작업 수를
해당 목표 값에 맞도록 오토 스케일링
CloudWatch 메트릭
ECSServiceAverageCPUUtilization
ECSServiceAverageMemoryUtilization
ALBRequestCountPerTarget
CPUTraffic
DesiredCount
Time
100%
0%
50%
10%
20%
30%
40%
60%
70%
80%
90%
5
30
10
15
20
25
Target CPU Utilization DesiredCount
오토 스케일링 대상 추적 조정 정책
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Fargate
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fargate, 개발에 집중
간단하고, 쉽고 강력한
서버리스 기반 컨테이너 배포
=인스턴스 관리 불필요 ECS Task
Native API 제공
자원 사용량 기반
과금
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Scheduling and Orchestration
Cluster Manager Placement Engine
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECS Instance ECS Instance ECS Instance ECS InstanceECS Instance ECS Instance
EC2
FARGATE
Notifications
Amazon ECS CLUSTER
Availability Zone #1 Availability Zone #2 Availability Zone #3
Subnet 2
172.31.2.0/24
Subnet 1
172.31.1.0/24
Subnet 3
172.31.3.0/24
Web
Shopping
Cart
EC2, Fargate 하이브리드 클러스터
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
클러스터 레벨 Isolation
PROD Cluster Infrastructure
DEV Cluster Infrastructure
BETA Cluster Infrastructure
QA Cluster Infrastructure
Web Web
Shopping
Cart
Shopping
Cart
Notifications NotificationsWeb
Shopping
Cart NotificationsWeb
Shopping
Cart
Shopping
Cart
Notifications NotificationsWeb Web
PROD CLUSTER BETA CLUSTER
DEV CLUSTER QA CLUSTER
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
작업 정의 등록
create
Cluster
• 인프라 Isolation 경계
• IAM 권한 boundary
run
Task
• 작업 정의 기반으로 Task 생성
• FARGATE launch 타입
create
Service
Application
Load Balancer
• 실행중인 작업 개수 유지
• ELB와 통합
• 비정상인 작업 자동 대체
Fargate 구성
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fargate Compute
{
"family": "scorekeep",
"cpu": "1 vCpu",
"memory": "2 gb",
"containerDefinitions": [
{
"name":“scorekeep-frontend",
"image":"xxx.dkr.ecr.us-east-
1.amazonaws.com/fe“,
"cpu": 256,
"memoryReservation": 512
},
{
"name":“scorekeep-api",
"image":"xxx.dkr.ecr.us-east-
1.amazonaws.com/api",
"cpu": 768,
"memoryReservation": 512
}
]
}
유닛
• CPU : 1 vCPU = 1024 CPU units
• Memory : MB (2^20)
작업 레벨 자원 할당
• 작업내의 전체 컨테이너 CPU/Memory양 할당
• 필수 입력 필수
• 과금의 기준
컨테이너 레벨 자원 할당
• 각 컨테이너에게 할당할 자원
• 입력 필수 아님 (옵션)
작업 레벨
자원 할당
컨테이너
레벨 자원
할당
작업 정의 Snippet
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
다양한 구성 옵션
총 50가지 유연한 구성 옵션
CPU Memory
256 (.25 vCPU) 512MB, 1GB, 2GB
512 (.5 vCPU) 1GB to 4GB
1024 (1 vCPU) 2GB to 8GB
2048 (2 vCPU) 4GB to 16GB
4096 (4 vCPU) 8GB to 30GB
CPU와 메모리 기준 초당 과금
1 vCPU = $0.00001406/초
1 GB Mem = $0.00000353/초
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC 통합
172.31.0.0/16
Subnet
172.31.1.0/24
Internet
VPC내의 다른 자원
EC2 LB DB etc.
Private IP
172.31.1.164
us-east-1a
us-east-1b
us-east-1c
ENI Fargate
작업Public /
208.57.73.13 /
Internet
Gateway
Fargate 작업을 서브넷 안에서 배포
• 작업 별로 ENI 생성하여 할당 가능
• 각각 ENI는 Subnet에 포함
Public IP 제공
작업 별 보안 그룹 제공
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fargate storage
레이어 스토리지 :
• 작업 당 10 GB 레이어 스토리지
• 이미지 레이어를 포함
Amazon EBS Ephemeral 스토리지
Fargate 볼륨 스토리지:
• 작업 당 4GB 할당
• 작업 내 컨테이너 간 인식 가능
• 작업 정의에서 Mount Point 설정 가능
Image Layers
Writable Layer
Image Layers
Writable Layer
Container 1 Container 2
작업 당 10GB 레이어 스토리지
Container 1 Container 2
4 GB 볼륨 스토리지
mount
/var/container1/data /var/container2/data
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Fargate 글로벌 고객 사례
”We don't want to
babysit any clusters. That
has nothing to do with
us”
Shimon Tolts
CTO, DATREE
“We moved to Fargate
because we need the
ability to scale quickly up
from baseline and get fine-
grained network control,
without having to manage
our own infrastructure”
Product Hunt
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
E L A S T I C C O N T A I N E R S E R V I C E F O R K U B E R N E T E S
3 Managed Kubernetes 마스터 노드
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
57%Kubernetes workloads are
running on AWS
—CNCF Survey
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kubernetes 마스터
API
server
Cloud
controller
Controller
manager
Scheduler Add-onsKubeDNS
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS 아키텍쳐
가용 영역 1
Master Master
가용 영역 2 가용 영역 3
Master
Workers Workers Workers
AWS Managed
Etcd EtcdEtcd
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS 아키텍쳐
mycluster.eks.amazonaws.com
EKS 워커 노드
Kubectl
AZ 1 AZ 2 AZ 3
Your AWS account
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Tenets
Tenet 1
엔터프라이즈 기업이 프로덕션 레벨
워크로드를 실행하는 플랫폼
Tenet 2
네이티브 및 업스트림
Kubernetes 경험 제공
Tenet 3
다른 AWS 서비스들과
손쉽게 연동
Tenet 4
Kubernetes 프로젝트
적극적 기여
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Heptio를 통한 IAM 연동
https://github.com/heptiolabs/kubernetes-aws-authenticator
An open-source approach to integrating
AWS IAM authentication with Kubernetes
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IAM 인증 + Kubectl
Kubectl
3) RBAC으로 AWS ID 인증
K8s API
1) AWS ID 전달
2) AWS ID 확인
4) K8s 액션 허용 / 거부 결정
AWS Auth
github.com/heptiolabs/kubernetes-aws-authenticator
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Nginx Pod
Java Pod
ENI
Secondary IPs:
10.0.0.1
10.0.0.2
Veth IP:
10.0.0.1
Veth IP:
10.0.0.2
Nginx Pod
Java Pod
ENI
Veth IP:
10.0.0.20
Veth IP:
10.0.0.22
Secondary IPs:
10.0.0.20
10.0.0.22
ec2.associateaddress()
VPC Subnet –
10.0.0.0/24
인스턴스 1 인스턴스 2
CNI
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
모니터링과 로깅을 위한 다양한 오픈소스 활용
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Heapster
EKS Master
Worker
Kubelet
cAdvisor
Heapster
Worker
cAdvisor
Kubelet
Kubectl
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Helm을 통해 손쉽게 Prometheus 구축
EKS Master
Worker
Kubectl
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
요약
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
요약
• 컨테이너는 경량성과 유연성을 기반으로 마이크로 서비스 아키텍처에 효율적
• AWS는 확장성이 뛰어난 컨테이너 오케스트레이션을 위해 ECS, ECR, Fargate, EKS 제공
• AWS의 견고한 인프라와 다양한 서비스와 완벽 통합
• Amazon Code Pipeline CI/CD 통합
• CloudWatch ECS 메트릭과 사용자 지정 메트릭을 통해 ECS 클러스터, 서비스 오토 스케일링
• AWS Fargate는 EC2를 관리할 필요없는 새로운 Launch 타입
• 전체 57%의 Kubernetes 워크로드가 AWS 환경에서 실행 중
• EKS는 Kubernetes 인증, 마스터 관리형, 다양한 오픈 소스 플러그인과 통합
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
더 자세한 것은 AWS 교육 정보를 참고하시기 바랍니다.
온라인 교육
AWS 무료 온라인 교육
자료, 실습 과정을
만나실 수 있습니다.
오프라인 공인 교육
AWS 공인 강사가 직접
유료 과정을 통해 다양한
교과 과정을 운영합니다.
AWS 공인 자격증
산업 현장에서 인정 받을 수
있는 다양한 전문 자격증
제도를 활용하세요.
더 자세한 사항은 AWS 교육 자료 웹 사이트를 참고하세요!
https://www.aws.training/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Innovate에 참여해주셔서 감사합니다!
본 세션이 끝난 후, 간단한 설문 조사에 응해 주시면 여러분의 피드백을
바탕으로 향후 더 좋은 콘텐츠를 준비해드리겠습니다.
다양한 AWS 콘텐츠를 온라인에서 만나보세요!
aws-korea-marketing@amazon.com
twitter.com/AWSKorea
facbook.com/AmazonWebServices
youtube.com/user/AWSKorea
slideshare.net/AWSKorea
twitch.tv/aws

마이크로 서비스를 위한 AWS의 다양한 컨테이너 옵션 l 이창수 솔루션즈 아키텍트

  • 1.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 마이크로 서비스를 위한 AWS의 다양한 컨테이너 옵션 이창수, AWS 솔루션즈 아키텍트
  • 2.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 목차 아마존 컨테이너 서비스 Amazon Elastic Container Service (ECS) AWS Fargate Amazon Elastic Container Service for Kubernetes (EKS)
  • 3.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 애플리케이션의 구성 런 타임 엔진 코드 디펜던시 구성
  • 4.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 문제점 • 수많은 애플리케이션 스택 • 각기 다른 하드웨어 배포 환경 다른 환경으로 쉽게 마이그레이션하고 실행하는 방법?
  • 5.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 솔루션, 컨테이너 효율성 : OS kernel 공유 이식성 : 이미지 기반 배포 유연성 : 마이크로 서비스 모듈화 신속성 : 가벼운 도커 이미지 컨테이너는 코드, 런타임, 라이브러리, 패키지를 포함
  • 6.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. VM과 컨테이너 비교 Server (Host) Host OS Hypervisor App 2 Guest OS Guest OS Guest OS Bins/Libs Bins/Libs Bins/Libs App 1 App 2 App 3 VM Server (Host) Host OS Docker Bins/Libs Bins/Libs Bins/Libs App 1 App 2 App 3 Container Hypervisor Guest OS
  • 7.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 아마존 컨테이너 서비스
  • 8.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 급속도로 증가하는 컨테이너 활용 규모 450+% 성장 수억개의 컨테이너 매주 새롭게 배포되는 컨테이너 수백만개의 인스턴스
  • 9.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 멀티 컨테이너의 Orchestration은?
  • 10.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 다양한 아마존의 컨테이너 서비스 Management 스케쥴링, 스케일링, 배포 전략 Hosting 컨테이너가 수행되는 곳 Amazon ECS Amazon EKS Amazon EC2 AWS Fargate Image Registry 컨테이너 이미지 저장소 Amazon ECR
  • 11.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 컨테이너 서비스 CI/CD 파이프 라인 통합 Amazon EC2 AWS CodePipeline Source Build Deploy AWS CodeCommit AWS CodeBuild Amazon RDS Amazon S3 Developer Control plane Data plane Backing service Registry CI/CD pipeline Amazon EFS
  • 12.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 컨테이너 서비스 CI/CD 파이프 라인 통합 AWS CodePipeline AWS CodeCommit AWS CodeBuild Developer Application Load Balancer Service 파이프 라인 생성 및 관리 코드 업 로드 이미지 확인 배포 후 상태 확인 registerTaskDefinition & updateService docker build & push imageDefinition.json source code
  • 13.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS (Elastic Container Service)
  • 14.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS AWS VPC 네트워킹 모드 …{ } 고급 작업 배치 AWS 서비스 간편한 연동 명령줄 인터페이스 전세계 다양한 활용사례 강력한 스케줄링 기능 자동 확장 CloudWatch 매트릭 부하분산
  • 15.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS 구성 요소 : 클러스터 Docker Task EC2 instance Container Docker Task EC2 instance Task Docker EC2 instance Task AZ 1 AZ 2 Container Container Container
  • 16.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS 구성 요소 : 클러스터 관리 엔진 Docker EC2 instance Docker EC2 instance Docker EC2 instance AZ 1 AZ 2 Cluster Management Engine Container Container Container ContainerContainer Container Task Task Task Task Task Task
  • 17.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS 구성 요소 : ECS Agent ECS agent EC2 instance ECS agent Docker EC2 instance Docker EC2 instance Docker AZ 1 AZ 2 Cluster Management Engine Container Container Container ContainerContainer Container Task Task Task Task Task Task ECS agent Agent Communication Service
  • 18.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS 아키텍쳐 ALB ALB AZ 1 AZ 2 user/scheduler Scheduler Cluster State Service Placement Engine Event Stream Internet ECS agent ECS agent ECS agent EC2 instance EC2 instance EC2 instance
  • 19.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS 구성 요소: 작업 (Task) Data Volume Containers Deploy EC2 instance Volume definitions Container definitions ECS 클러스터에서 배포되는 컨테이너의 최소 단위 작업 정의 내용을 기반으로 배포 한 작업 안의 컨테이너들은 모두 같은 호스트 EC2에 배포 { "family": “scorekeep", "containerDefinitions": [ { "name":“scorekeep-frontend", "image":"xxx.dkr.ecr.us-east- 1.amazonaws.com/fe" }, { "name":“scorekeep-api", "image":"xxx.dkr.ecr.us-east- 1.amazonaws.com/api" } ] } Task Definition – scorekeep:10 scorekeep-frontend scorekeep-api Task
  • 20.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. CloudWatch를 활용한 작업 log 수집 및 처리 CloudWatch Logs Amazon S3 Amazon Kinesis AWS Lambda Amazon ElasticSearch Amazon ECS Store Stream Process Search CloudWatch Logs CloudWatch Logs CloudWatch Logs
  • 21.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. IAM 작업 Role AWS IAM Amazon DynamoDB S3 AWS IAM DynamoDBRole S3Role Amazon ECS IAM 작업 Role Identity Access Management (IAM) ECS 작업
  • 22.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS 구성 요소 : 서비스 • 설정한 작업 수 자동 유지 및 복구 • 서비스 업데이트 시 blue/green 배포 가능 • ALB을 통해 효율적인 부하 분산 • 서비스 오토스케일링 설정 가능 Service Application Load Balancing 서비스 오토스케일링 작업 서비스
  • 23.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS : 서비스 ◉ AWS 관리 콘솔  ECS  Clusters  Services  Create
  • 24.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECS : 서비스 blue/green Task DesiredCount = 4, MinimumHealthyPercent = 100%, MaximumPercent =200%
  • 25.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 작업 배치 전략 Binpacking Spread Affinity Distinct Instance
  • 26.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 작업 배치 전략 ◉ AWS management console  ECS  Clusters  Services  Create  Task Placement Task  Run test  Task Placement
  • 27.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. CloudWatch ECS 메트릭 2개 차원 • ClusterName • ServiceName 4개 메트릭 • CPUReservation • MemoryReservation • CPUUtilization • MemoryUtilization 컨테이너 인스턴스 … Cluster 작업 정의 작업 서비스 CloudWatch ECS 메트릭 CloudWatch EC2 메트릭 컨테이너 인스턴스 컨테이너 인스턴스
  • 28.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 커스텀 메트릭 Mapbox는 31개 ECS 커스텀 메트릭 사용 • AgentConnectedPercent • FailedTaskPlacement • ActiveInstanceCount • StatusCheckFailedInstances • RunningTasksPerInstances • Spot Termination …
  • 29.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. ECS 클러스터 오토 스케일 아웃 Event: Per 클러스터 CPU,메모리 reservation, utilization 혹은 커스텀 메트릭 새로운 서비스 Amazon ECS ECS 클러스터 CloudWatch 개발자 CloudWatch 이벤트
  • 30.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. ECS 클러스터 오토 스케일 인 Draining CloudWatch Event: Per 클러스터 CPU,메모리 reservation, utilization 혹은 커스텀 메트릭 Amazon ECS ECS 클러스터
  • 31.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Service Auto Scaling ◉ AWS management console  ECS  Clusters  Services  Configure Service Auto Scaling Amazon EC2 Service Resource buffer (+~15%)
  • 32.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 측정 대상의 목표 값 설정하면 자동 조정 (예: CPU utilization 50%) 대상 추적을 통해 서비스의 작업 수를 해당 목표 값에 맞도록 오토 스케일링 CloudWatch 메트릭 ECSServiceAverageCPUUtilization ECSServiceAverageMemoryUtilization ALBRequestCountPerTarget CPUTraffic DesiredCount Time 100% 0% 50% 10% 20% 30% 40% 60% 70% 80% 90% 5 30 10 15 20 25 Target CPU Utilization DesiredCount 오토 스케일링 대상 추적 조정 정책
  • 33.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon Fargate
  • 34.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Fargate, 개발에 집중 간단하고, 쉽고 강력한 서버리스 기반 컨테이너 배포 =인스턴스 관리 불필요 ECS Task Native API 제공 자원 사용량 기반 과금
  • 35.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Scheduling and Orchestration Cluster Manager Placement Engine ECS AMI Docker agent ECS agent EC2 Instance ECS AMI Docker agent ECS agent EC2 Instance ECS AMI Docker agent ECS agent EC2 Instance
  • 36.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. ECS Instance ECS Instance ECS Instance ECS InstanceECS Instance ECS Instance EC2 FARGATE Notifications Amazon ECS CLUSTER Availability Zone #1 Availability Zone #2 Availability Zone #3 Subnet 2 172.31.2.0/24 Subnet 1 172.31.1.0/24 Subnet 3 172.31.3.0/24 Web Shopping Cart EC2, Fargate 하이브리드 클러스터
  • 37.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 클러스터 레벨 Isolation PROD Cluster Infrastructure DEV Cluster Infrastructure BETA Cluster Infrastructure QA Cluster Infrastructure Web Web Shopping Cart Shopping Cart Notifications NotificationsWeb Shopping Cart NotificationsWeb Shopping Cart Shopping Cart Notifications NotificationsWeb Web PROD CLUSTER BETA CLUSTER DEV CLUSTER QA CLUSTER
  • 38.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 작업 정의 등록 create Cluster • 인프라 Isolation 경계 • IAM 권한 boundary run Task • 작업 정의 기반으로 Task 생성 • FARGATE launch 타입 create Service Application Load Balancer • 실행중인 작업 개수 유지 • ELB와 통합 • 비정상인 작업 자동 대체 Fargate 구성
  • 39.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Fargate Compute { "family": "scorekeep", "cpu": "1 vCpu", "memory": "2 gb", "containerDefinitions": [ { "name":“scorekeep-frontend", "image":"xxx.dkr.ecr.us-east- 1.amazonaws.com/fe“, "cpu": 256, "memoryReservation": 512 }, { "name":“scorekeep-api", "image":"xxx.dkr.ecr.us-east- 1.amazonaws.com/api", "cpu": 768, "memoryReservation": 512 } ] } 유닛 • CPU : 1 vCPU = 1024 CPU units • Memory : MB (2^20) 작업 레벨 자원 할당 • 작업내의 전체 컨테이너 CPU/Memory양 할당 • 필수 입력 필수 • 과금의 기준 컨테이너 레벨 자원 할당 • 각 컨테이너에게 할당할 자원 • 입력 필수 아님 (옵션) 작업 레벨 자원 할당 컨테이너 레벨 자원 할당 작업 정의 Snippet
  • 40.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 다양한 구성 옵션 총 50가지 유연한 구성 옵션 CPU Memory 256 (.25 vCPU) 512MB, 1GB, 2GB 512 (.5 vCPU) 1GB to 4GB 1024 (1 vCPU) 2GB to 8GB 2048 (2 vCPU) 4GB to 16GB 4096 (4 vCPU) 8GB to 30GB CPU와 메모리 기준 초당 과금 1 vCPU = $0.00001406/초 1 GB Mem = $0.00000353/초
  • 41.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. VPC 통합 172.31.0.0/16 Subnet 172.31.1.0/24 Internet VPC내의 다른 자원 EC2 LB DB etc. Private IP 172.31.1.164 us-east-1a us-east-1b us-east-1c ENI Fargate 작업Public / 208.57.73.13 / Internet Gateway Fargate 작업을 서브넷 안에서 배포 • 작업 별로 ENI 생성하여 할당 가능 • 각각 ENI는 Subnet에 포함 Public IP 제공 작업 별 보안 그룹 제공
  • 42.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Fargate storage 레이어 스토리지 : • 작업 당 10 GB 레이어 스토리지 • 이미지 레이어를 포함 Amazon EBS Ephemeral 스토리지 Fargate 볼륨 스토리지: • 작업 당 4GB 할당 • 작업 내 컨테이너 간 인식 가능 • 작업 정의에서 Mount Point 설정 가능 Image Layers Writable Layer Image Layers Writable Layer Container 1 Container 2 작업 당 10GB 레이어 스토리지 Container 1 Container 2 4 GB 볼륨 스토리지 mount /var/container1/data /var/container2/data
  • 43.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. AWS Fargate 글로벌 고객 사례 ”We don't want to babysit any clusters. That has nothing to do with us” Shimon Tolts CTO, DATREE “We moved to Fargate because we need the ability to scale quickly up from baseline and get fine- grained network control, without having to manage our own infrastructure” Product Hunt
  • 44.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. E L A S T I C C O N T A I N E R S E R V I C E F O R K U B E R N E T E S 3 Managed Kubernetes 마스터 노드
  • 45.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 57%Kubernetes workloads are running on AWS —CNCF Survey
  • 46.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Kubernetes 마스터 API server Cloud controller Controller manager Scheduler Add-onsKubeDNS
  • 47.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. EKS 아키텍쳐 가용 영역 1 Master Master 가용 영역 2 가용 영역 3 Master Workers Workers Workers AWS Managed Etcd EtcdEtcd
  • 48.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. EKS 아키텍쳐 mycluster.eks.amazonaws.com EKS 워커 노드 Kubectl AZ 1 AZ 2 AZ 3 Your AWS account
  • 49.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. EKS Tenets Tenet 1 엔터프라이즈 기업이 프로덕션 레벨 워크로드를 실행하는 플랫폼 Tenet 2 네이티브 및 업스트림 Kubernetes 경험 제공 Tenet 3 다른 AWS 서비스들과 손쉽게 연동 Tenet 4 Kubernetes 프로젝트 적극적 기여
  • 50.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Heptio를 통한 IAM 연동 https://github.com/heptiolabs/kubernetes-aws-authenticator An open-source approach to integrating AWS IAM authentication with Kubernetes
  • 51.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. IAM 인증 + Kubectl Kubectl 3) RBAC으로 AWS ID 인증 K8s API 1) AWS ID 전달 2) AWS ID 확인 4) K8s 액션 허용 / 거부 결정 AWS Auth github.com/heptiolabs/kubernetes-aws-authenticator
  • 52.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Nginx Pod Java Pod ENI Secondary IPs: 10.0.0.1 10.0.0.2 Veth IP: 10.0.0.1 Veth IP: 10.0.0.2 Nginx Pod Java Pod ENI Veth IP: 10.0.0.20 Veth IP: 10.0.0.22 Secondary IPs: 10.0.0.20 10.0.0.22 ec2.associateaddress() VPC Subnet – 10.0.0.0/24 인스턴스 1 인스턴스 2 CNI
  • 53.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 모니터링과 로깅을 위한 다양한 오픈소스 활용
  • 54.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Heapster EKS Master Worker Kubelet cAdvisor Heapster Worker cAdvisor Kubelet Kubectl
  • 55.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Helm을 통해 손쉽게 Prometheus 구축 EKS Master Worker Kubectl
  • 56.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 요약
  • 57.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 요약 • 컨테이너는 경량성과 유연성을 기반으로 마이크로 서비스 아키텍처에 효율적 • AWS는 확장성이 뛰어난 컨테이너 오케스트레이션을 위해 ECS, ECR, Fargate, EKS 제공 • AWS의 견고한 인프라와 다양한 서비스와 완벽 통합 • Amazon Code Pipeline CI/CD 통합 • CloudWatch ECS 메트릭과 사용자 지정 메트릭을 통해 ECS 클러스터, 서비스 오토 스케일링 • AWS Fargate는 EC2를 관리할 필요없는 새로운 Launch 타입 • 전체 57%의 Kubernetes 워크로드가 AWS 환경에서 실행 중 • EKS는 Kubernetes 인증, 마스터 관리형, 다양한 오픈 소스 플러그인과 통합
  • 58.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 더 자세한 것은 AWS 교육 정보를 참고하시기 바랍니다. 온라인 교육 AWS 무료 온라인 교육 자료, 실습 과정을 만나실 수 있습니다. 오프라인 공인 교육 AWS 공인 강사가 직접 유료 과정을 통해 다양한 교과 과정을 운영합니다. AWS 공인 자격증 산업 현장에서 인정 받을 수 있는 다양한 전문 자격증 제도를 활용하세요. 더 자세한 사항은 AWS 교육 자료 웹 사이트를 참고하세요! https://www.aws.training/
  • 59.
    © 2018, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. AWS Innovate에 참여해주셔서 감사합니다! 본 세션이 끝난 후, 간단한 설문 조사에 응해 주시면 여러분의 피드백을 바탕으로 향후 더 좋은 콘텐츠를 준비해드리겠습니다. 다양한 AWS 콘텐츠를 온라인에서 만나보세요! aws-korea-marketing@amazon.com twitter.com/AWSKorea facbook.com/AmazonWebServices youtube.com/user/AWSKorea slideshare.net/AWSKorea twitch.tv/aws