20180313 amazon container services アップデート
TRANSCRIPT
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Container Services
アップデート
Ryosuke Iwanaga, Solutions Architect
Amazon Web Services Japan K.K.
2018.03
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
• Amazon Container Services アップデート
• コンテナCI/CDパイプライン
• コンテナのAuto Scaling
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon EC2
AWSCodePipeline
Source Build Deploy
AWSCodeCommit
AWSCodeBuild
Amazon RDS Amazon S3Developer
Control plane
Data plane
Backing service
Registry
CI/CD pipeline
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elastic Container Registry (ECR)
フルマネージドの高可用性・スケーラブルなレジストリエンドポイントにアクセスできるならAWS外からでも利用可能
AWS IAMによる強力な認証管理機構pullのみの権限、クロスアカウントアクセスも可能
ライフサイクルポリシーでイメージの自動クリーンアップ何日以前や何個以上は自動削除といったルールを組み合わせて設定
NEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS上の本番環境のコンテナを支える
AWS VPCネットワークモード
タスク配置
他のAWSサービスとの深い連携
ECS CLI…{ }
グローバル展開
強力なスケジューラ
オートスケーリング
CloudWatch メトリクス
ロードバランサ
Linux & Windows
NEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS VPC ネットワークモード
Task毎にENIを自動割り当てSecurity GroupをTask毎に設定可能
Task内のコンテナはlocalhostを共有
Link不要で互いにアクセス可能
VPC内の他のリソースへPrivate IPで通信が可能
FargateではPublic IPの割当も可能
172.31.0.0/16
Subnet 172.31.1.0/24
Internet
Other Entities in VPC
EC2 ELB RDS etc.
Elastic Network Interface (ENI)Public IP / Private IP
208.57.73.13 / 172.31.1.164
us-east-1a
us-east-1b
us-east-1c
NEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECSアップデート、その他
Linux capabilities ADD/DROP
Task metadata / metrics
Device / Init flag support
Windows support GA
Task level CPU/Memory limit
Circuit breaking for Service
Health check grace period
Container health check
NEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
63%のKubernetes利用者がAWSを今日利用している—CNCF アンケートよりhttps://www.cncf.io/blog/2017/06/28/survey-shows-kubernetes-leading-orchestration-platform/https://www.cncf.io/blog/2017/12/06/cloud-native-technologies-scaling-production-applications/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elastic Container Service for Kubernetes (EKS)
Tenet 1
EKSはエンタープライズ企業が本番のワークロードを実行するためのプラット
フォームであること
Tenet 2
EKSはネイティブで最新のKubernetesの体験を提供すること
Tenet 3
EKSユーザが他のAWSサービスを使う時、シームレスな連携を実現し不要な
作業を取り除くこと
Tenet 4
EKSチームは積極的にKubernetesプロジェクトに貢献していくこと
NEW!! (Preview)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
kubectl
3) AWSアイデンティティをRBACで認可する
k8s API
1) AWSアイデンティティを渡す
2) AWSアイデンティティを検証する
4) k8sのアクションが許可・拒否される
AWS Auth
IAM 認証 + kubectl
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アプリケーションの開発に集中したい
Amazon EC2
• アプリ開発してデプロイ• コンテナのAuto Scale• コンテナのセキュリティ管理
• OSのプロビジョン• OSのセキュリティ管理• インスタンスのAuto Scale
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
計算リソースの使い方を根本的に変える
簡素で、使いやすく、強力な
新しいリソース利用モデル
=インスタンス管理不要
タスクネイティブAPI
リソースベースの価格
NEW!!
© 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.
サービスレベルアグリーメント + コンプライアンス
99.99
NEW!!
HIPAA 資格要件を満たすとともに、ISO、PCI、SOC 1、SOC 2、および SOC 3 コンプライアンスの基準を満たしています
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
コンテナのCI/CDパイプライン
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
なぜCI/CDパイプラインが重要なのか?
• 誰がやっても同じ様にデプロイできること
• イメージがどうやって作られどこで使われてるか把握
• アプリ毎に統一された手法を利用する
しかし、CI/CDパイプラインの実装や構築自体は、典型的な差別化を産まない重労働
→ AWS CodePipeline / AWS CodeBuild
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodePipeline
柔軟なCI/CDパイプラインをフルマネージド
Source, Build, Test, Deployを複雑に組合せ
並列実行や、手動承認も設定可能
Deploy TargetにECS Serviceも対応
ユースケース
テスト環境にデプロイ後、各種テスト実行
カナリア、リージョンデプロイ
NEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeBuild
マネージドの実行環境
ビルドやテスト等が主な目的
実行環境はDockerイメージ
各種言語対応の環境
Dockerイメージのビルドも可能
Docker 17.09.0対応イメージ有
CodePipelineとも連携可能
もちろん単体でも利用可能
version: 0.2
phases: pre_build: commands: - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - REPOSITORY_URI=0123456789.dkr.ecr.us-east-1.amazonaws.com/fargate-demo - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) build: commands: - docker build -t $REPOSITORY_URI:latest . - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: - docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:$IMAGE_TAG - printf '[{"name":"app","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imageDefinition.json
artifacts: files: imageDefinition.json
buildspec.yaml
NEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWSCodePipeline
AWSCodeCommit
AWSCodeBuild
Developer
ApplicationLoad Balancer
Service
パイプライン確認、手動承認
コードのチェックイン
ビルド済イメージの確認
デプロイ後の状態確認
registerTaskDefinition & updateService
docker build & push
imageDefinition.json
source code
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
コンテナのAuto Scaling
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECSの特徴: Target Trackingとの連携
メトリクスに対してターゲットの値を設定するだけ
(例: CPU使用率 50%)
その値に近づく様に、Application Auto Scalingが自動的にServiceのDesiredCountを調整
ECSではコンソールからも設定可能ECSServiceAverageCPUUtilization
ECSServiceAverageMemoryUtilization
ALBRequestCountPerTarget
CP
UTr
affic
Des
iredC
ount
Time
100%
0%
50%
10%
20%
30%
40%
60%
70%
80%
90%
5
30
10
15
20
25
Target CPU Utilization DesiredCountNEW!!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service
Fargateを利用したコンテナAuto Scalingの優位性
Fargateの場合• Serviceのスケールに応じて自然にコ
ンテナが起動・終了する
• コンテナの起動時間に対してのみ課金
EC2の場合• インスタンスのリソースも上手くスケ
ールさせる必要があり煩雑
• 余分に持っているバッファ分もインスタンスの課金が必要
Amazon EC2
ServiceResource
buffer(+~15%)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめAmazon Container Services
CI/CDパイプラインAuto Scaling
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
参考資料
• Amazon Container Services Page
• Containers on AWS - State of the Union - CON201 - re:Invent 2017 Slides /
Video
• Introducing AWS Fargate - CON214 - re:Invent 2017 Slides / Video
• Deep Dive into AWS Fargate - CON333 - re:Invent 2017 Slides / Video
• Introducing Amazon EKS - CON215 - re:Invent 2017 Slides / Video
• Deep Dive into Amazon EKS - CON409 - re:Invent 2017 Slides / Video
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thanks!