More Related Content
Similar to AWS에서 Kubernetes 실전 활용하기::유병우::AWS Summit Seoul 2018
Similar to AWS에서 Kubernetes 실전 활용하기::유병우::AWS Summit Seoul 2018 (20)
More from Amazon Web Services Korea
More from Amazon Web Services Korea (20)
AWS에서 Kubernetes 실전 활용하기::유병우::AWS Summit Seoul 2018
- 1. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
유병우
Buzzvil
Kubernetes in Action
on AWS
- 2. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Container orchestration tool?
Why Kubernetes?
Why Kops?
Demo
- 3. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Container orchestration tool?
- 4. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Container?
• State?
• Relation?
• History?
- 5. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Container? - Relation
격리된 공간가상화
Overhead
- 6. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Container? - History
# Use an official Python runtime as a parent image
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
- 7. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Container orchestration tool?
EC2
Django
EC2
Django
EC2
Django
EC2
Go
EC2
Go
EC2
Go
2 Apps + 2 AS Groups + 1 ALB
Docker
도입
Django
Go
Application load balancer
Nginx
3 Apps + 1 AS Groups
Container orchestration tool 을 통해 이걸 해결해보자!
- 8. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Kubernetes?
- 9. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
용어정리
- 10. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Cluster
Cluster / Node / Pod
- 11. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
RC / Deployment / Service
• ReplicationController (ReplicaSet)
• 하나의 Pod 상태를 공유하는 Set
• Deployment?
• 업데이트! (RC 가 추가됨)
• 어떻게 배포할지 설정 가능
How to expose them?
Service
- 12. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Kubernetes?
• Automatic binpacking
• Horizontal scaling
• Automated rollouts and rollbacks
• Self-healing
• Service discovery and load balancing
- 13. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automatic binpacking
- 14. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automatic binpacking
Node 1 (4 CPU / 8G)
2 CPU /
2G
Node 2 (4 CPU / 8G)
2 CPU /
2G
2 CPU /
2G1 CPU /
2G
- 15. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automatic binpacking
Node 1 (4 CPU / 8G)
2 CPU /
2G
Node 2 (4 CPU / 8G)
2 CPU /
2G
2 CPU /
2G1 CPU /
2G
- 16. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automatic binpacking
Node 1 (4 CPU / 8G)
2 CPU /
2G 1 CPU /
2G
Node 2 (4 CPU / 8G)
2 CPU /
2G
2 CPU /
2G1 CPU /
2G
- 17. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automatic binpacking
Node 1 (4 CPU / 8G)
2 CPU /
2G
Node 2 (4 CPU / 8G)
2 CPU /
2G
2 CPU /
2G1 CPU /
2G
1 CPU /
2G
- 18. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automatic binpacking
2 CPU / 16G
2 CPU / 4G
4 CPU / 8G
2 CPU
/ 2G 1 CPU
/ 2G
2 CPU / 16G
1 CPU
/ 4G 1 CPU
/ 8G
4 CPU / 8G
2 CPU
/ 2G 1 CPU
/ 2G
2 CPU / 16G
1 CPU
/ 4G 1 CPU
/ 8G
4 CPU / 8G
2 CPU
/ 2G 1 CPU
/ 2G
2 CPU / 16G
1 CPU
/ 6G
1 CPU
/ 2G
4 CPU / 8G
2 CPU
/ 2G 1 CPU
/ 2G
3 CPU /
4G 1 CPU /
8G
- 19. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Horizontal scaling
- 20. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Horizontal scaling
- 21. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automated rollouts and rollbacks
- 22. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automated rollouts and rollbacks
https://kubernetes.io/docs/tutorials/kubernetes-basics/update-intro/
- 23. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Automated rollouts and rollbacks
- 24. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Self-healing
- 25. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Self-healing
Node 1
App 1
App 2
Node 2
App 2
Node 3
App 3
Master
Contoller
Scheduler
- 26. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Self-healing
Node 1
App 1
App 2
Node 2
App 2
Node 3
App 3’
Master
Contoller
Scheduler
- 27. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Self-healing
Node 1
App 1
App 2
Node 2
App 2
Node 3
App 3
Master
Contoller
Scheduler
- 28. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Self-healing
Node 1
App 1
App 2
Node 2
App 2
App 3
Master
Contoller
Scheduler
- 29. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Service discovery and load
balancing
- 30. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Service discovery and load balancing
{{service-name}}.{{namespace}}.svc.cluster.local
- 31. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Service discovery and load balancing
• Internal
• ClusterIP
• External
• LoadBalancer
• NodePort
- 32. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why Kops?
- 33. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why kops?
• AWS 위에 Kubernetes clusters 관리를 자동화
AWS AWS
Kube
- 34. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Kube
+ α
Why kops?
• AWS 위에 Kubernetes clusters 관리를 자동화
S3 IAM VPC
EC2 Route53
- 35. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why kops?
• AWS 위에 Kubernetes clusters 관리를 자동화
• 고가용성(Highly Available) Kubernetes Masters
- 36. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Why kops?
• AWS 위에 Kubernetes clusters 관리를 자동화
• 고가용성(Highly Available) Kubernetes Masters
• State-sync model (dry-runs & Idempotency)
• kops create cluster --zones us-west-2a ${NAME}
• kops update cluster ${NAME} --yes
- 37. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Demo
- 38. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Prerequisites
• Install CLI tools – kops / kubectl
• IAM permissions
- 39. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Demo
• Cluster 구성 (1 master & 2 nodes)
• Web app & Nginx proxy 구성
• External load balancer 구성
• Auto scaling 설정
- 40. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
VPC
Overview
Cluster
Load balancer
hello-go
Pod
Pod
Pod Pod
autoscaler
Nginx
Pod
Cluster
autoscaler
- 41. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
VPC
Cluster 구성
Cluster
Master
Node Node
- 42. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Cluster 구성
• 환경변수 설정
• export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
• export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)
• export S3_BUCKET_NAME=k8s-state-test-honeyscreen-com
• export KOPS_STATE_STORE=s3://${S3_BUCKET_NAME}
• export CLUSTER_NAME=k8s-test.honeyscreen.com
• export SSH_PUBLIC_KEY=~/.ssh/id_rsa.pub
• export VPC={{VPC-ID}}
• export CLUZTER_REGION=ap-northeast-2
• export CLUSTER_ZONE=${CLUZTER_REGION}a
- 43. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Cluster 구성
• S3 Bucket 만들기 / Cluster 생성
- 44. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Cluster 구성
• Cluster 확인 및 수정
- 45. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Cluster 구성
• Cluster 적용
• kops update cluster --name $CLUSTER_NAME –yes
• Cluster 업데이트
• kops edit instancegroup nodes
• kops update cluster --name $CLUSTER_NAME –yes
- 46. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Cluster 구성
• Dashboard 설치
• kubectl create -f https://raw.githubusercontent.com/kubernetes/kops/master/addons/kubernetes-
dashboard/v1.8.1.yaml
• http://api.k8s-test.honeyscreen.com/ui
- 47. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
VPC
Web app & Nginx proxy 구성
Cluster
hello-go
Pod
Pod
Pod
Nginx
Pod
- 48. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app & Nginx proxy 구성
• Web app - hello-go
• Source code
• Return Git revision
• Build
• kube/app-hello-go.yaml
• kube/svc-hello-go.yaml
• Nginx proxy
• kube/app-nginx.yaml
• kube/svc-nginx.yaml
- 49. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app - hello-go
• main.go
- 50. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app – build-docker.sh
• hello
- 51. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app – kube/app-hello-go.yaml
- 52. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app – kube/svc-hello-go.yaml
- 53. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app – kube/app-nginx.yaml
- 54. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
VPC
External load balancer 구성
Cluster
Load balancer
hello-go
Pod
Pod
Pod
Nginx
Pod
- 55. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Web app – kube/svc-nginx.yaml
- 56. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
External load balancer 구성
• Expose Nginx to Load balancer
• kube/svc-nginx.yaml
• Load balancer 확인
• Route53 에서 sub domain 할당
- 57. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
deploy.sh
- 58. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
VPC
Auto scaling 설정
Cluster
Load balancer
hello-go
Pod
Pod
Pod Pod
autoscaler
Nginx
Pod
Cluster
autoscaler
- 59. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Auto scaling - Pod
• kube/hpa-hello-go.yaml
- 60. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Auto scaling - Cluster
• kube/app-autoscaler.yaml
- 61. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Increase load
- 62. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Increase load
- 63. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Decrease load
- 64. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Decrease load
- 65. © 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
References
• Github
https://github.com/urunimi/kube-sample/
• E-mail
hovan@hovans.com
ben.yoo@buzzvil.com
We are hiring!