"From zero to Blue/Green deployments on Amazon ECS", Massimo Re Ferré, AWS Dev Day Kyiv 2019 "1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
K Y I V
11.05.2019
CI/CD for Modern Applications
Massimo Re Ferrè
Developer Advocate
Amazon Web Services
2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Who Am I ?
Amazon Web Services (Developer Advocate)
VMware (Solutions Architect and Technical Product Manager)
IBM (Professional Services and Solutions Architect)
Developer (many kilos ago)
Email: mreferre@amazon.com
Twitter: @mreferre
Github: github.com/mreferre
3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How software value gets created (in the old model)
Monolithic
application
“Time to user”: months / years
Very heavy
manual
integrations
4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How software value gets created (in the new model)
“Time to user”: hours / days
Small
independent
components…
End-to-end
(hands off)
automation
…. with
different
release cycles
5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What are the compute options to run my code?
Instances
Containers
Lambda
Containers control plane
Containers data plane
8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS compute abstractions layers
AWS
Lambda
Amazon
EC2
Metal
AWS
Fargate
Amazon
EKS
physicalseverVMcontainerfunction
Levelofabstraction
Provider space
(managed by AWS)
Consumer space
(managed by the customer)
Amazon
ECS
For this session, we are going to focus on this (as an example)
9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ECS w/ EC2 data plane
AWS Account Cust Account
VPC
Amazon EC2
TaskService
ENI
aws ecs run-task … --launch-type EC2 …
You have to manage this
capacity (e.g. with ASGs)
Amazon ECS
10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Scaling metrics
https://garbe.io/blog/2017/04/12/a-better-solution-to-ecs-autoscaling/
https://medium.com/thron-tech/aws-ecs-host-auto-scaling-with-custom-cloudwatch-metrics-and-aws-lambda-b9a9f55faf1d
11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Need for speed – (all lines are made up)
12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Need for speed – real example (all lines are for real)
13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ECS w/ FARGATE data plane
AWS Account
AWS Fargate
Cust Account
VPC
TaskService
ENI
aws ecs run-task … --launch-type FARGATE …
You don’t have to manage
capacity
Amazon ECS
14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green and the pressure on infrastructure
Task
Auto Scaling group
Instance
Task Task Task Task Task Task Task Task Task Task Task
Instance Instance Instance
Task Task Task Task Task Task Task Task Task Task Task Task
AWS Fargate
On ECS/EC2 On ECS/Fargate
16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green and the pressure on infrastructure
Task
Auto Scaling group
Instance
Task Task Task Task Task Task Task Task Task Task Task
Task Task Task Task Task Task Task Task Task Task Task Task
Instance Instance Instance
Task Task Task Task Task Task Task Task Task Task Task Task
Task Task Task Task Task Task Task Task Task Task Task Task
AWS Fargate
On ECS/EC2 On ECS/Fargate
17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green and the pressure on infrastructure
Task
Auto Scaling group
Instance
Task Task Task Task Task Task Task Task Task Task Task
Task Task Task Task Task Task Task Task Task Task Task Task
Instance Instance Instance
Task Task Task Task Task Task Task Task Task Task Task Task
Task Task Task Task Task Task Task Task Task Task Task Task
AWS Fargate
Instance Instance Instance Instance
On ECS/EC2 On ECS/Fargate
18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green and the pressure on infrastructure
Auto Scaling group
Instance Instance Instance Instance
AWS Fargate
Instance Instance Instance Instance
Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task
On ECS/EC2 On ECS/Fargate
19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green and the pressure on infrastructure
AWS Fargate
Auto Scaling group
Instance Instance Instance Instance
Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task Task
On ECS/EC2 On ECS/Fargate
20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green deployments
Service
Target-Group-Green Task Task Task
Service
Amazon ECR
Amazon ECS
Amazon ALB
Image1
THIS IS VER1
21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green deployments
Service
Target-Group-Green
Target-Group-Blue
Task Task Task
Service
Amazon ECR
Amazon ECS
Amazon ALB
Image1
THIS IS VER1
THIS IS VER1
22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green deployments
Service
Target-Group-Green
Target-Group-Blue
Task Task Task
Service
AWS CodeCommit AWS CodeBuild
AWS CodePipeline
AWS CodeDeploy Amazon ECR
Amazon ECS
Amazon ALB
Image1
THIS IS VER1
THIS IS VER1
<html>
<body>
<h1>THIS IS VER 1</h1>
</body>
</html>
23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green deployments
Service
Target-Group-Green
Target-Group-Blue
Task Task Task
Service
AWS CodeCommit AWS CodeBuild
AWS CodePipeline
AWS CodeDeploy Amazon ECR
Amazon ECS
<html>
<body>
<h1>THIS IS VER 1</h1>
</body>
</html>
<html>
<body>
<h1>THIS IS A NEW VER</h1>
</body>
</html>
Amazon ALB
Image1
Image2
THIS IS VER1
THIS IS VER1
Trigger
24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green deployments
Service
Target-Group-Green
Target-Group-Blue
Task Task Task
Service
AWS CodeCommit AWS CodeBuild
AWS CodePipeline
AWS CodeDeploy Amazon ECR
Amazon ECS
Amazon ALB
Image1
Image2
Task Task TaskTHIS IS A NEW VER
THIS IS VER1
<html>
<body>
<h1>THIS IS A NEW VER</h1>
</body>
</html>
25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green deployments
Service
Target-Group-Green
Target-Group-Blue Service
AWS CodeCommit AWS CodeBuild
AWS CodePipeline
AWS CodeDeploy Amazon ECR
Amazon ECS
Amazon ALB
Image1
Image2
Task Task TaskTHIS IS A NEW VER
THIS IS A NEW VER
<html>
<body>
<h1>THIS IS A NEW VER</h1>
</body>
</html>
26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo?