Breaking the monolith - Containers
Name of Presenter
Date
Microservices
Changes to the architectural
patterns
When the impact of change is small,
release velocity can increase
Monolith Microservices
Does everything Do one thing
4
Microservices architectures
APPLICATION
Mobile
client
EVENT
API
MICROSERVICE
API
MICROSERVICE
Client
EVENT
MICROSERVICE
API
MICROSERVICE
API
IoT
MICROSERVICE
PERSISTENCE PERSISTENCE
5
Cloud-native architectures are
small pieces, loosely joined
6
Containers
The Problem
Static
website
• Different application stacks Web
fronted
• Different hardware deployment Background
environments workers
• How to run all applications User DB
across different environments?
Analytics
DB
• How to easily migrate from one
environment to another? Queue
Single
QA Onsite Public Contributor’s Customer
Dev VM Prod
Server Cluster Cloud laptop Servers
Server
8
The Solution
Static
website
• Unit of software delivery Web
fronted
• Lightweight, portable, consistent
Background
• Deploy and run everywhere workers
• Deploy and run anything User DB
Analytics
DB
Queue
Single
QA Onsite Public Contributor’s Customer
Dev VM Prod
Server Cluster Cloud laptop Servers
Server
9
What is a container?
• Containers share a machine's OS kernel.
• They start instantly and use less compute and RAM.
• Images are constructed from file system layers and share common files. This minimizes
disk usage and image downloads are much faster.
10
Docker
Client DOCKER_HOST Registry
docker build Docker daemon
Docker daemon
docker pull Containers Images
Docker client
docker run
• Lightweight container virtualization platform.
• Tools to manage and deploy your applications.
• Licensed under the Apache 2.0 license.
• Built by Docker, Inc.
13
Container orchestration
At first there was
Amazon EC2
15
Then Docker!
Containers
EC2 Instance
Customers started containerizing applications
within EC2 instances
16
Customers needed an easier way to manage large clusters of
instances and containers
18
Container services on AWS
Image Repository
Amazon Elastic
Where the Docker images are
Container Registry
stored
(ECR)
19
Container services on AWS
Host Amazon EC2 AWS Fargate
Where the containers are
executed
Image Repository
Amazon Elastic
Where the Docker images are
Container Registry
stored
(ECR)
20
Container services on AWS
Administration Amazon Elastic
Amazon Elastic
Implementation, scheduling, Container Service
Container Service
scale and administration of for Kubernetes
(ECS)
the containers (EKS)
Host Amazon EC2 AWS Fargate
Where the containers are
executed
Image Repository
Amazon Elastic
Where the Docker images are
Container Registry
stored
(ECR)
21
Amazon Elastic Container Service (ECS)
Scheduling and Orchestration
ECS
Cluster Manager Placement Engine
23
Cluster overview
Amazon ECS
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK Amazon
ECS
AGENT ECS
Container Container COMMUNICATION SERVICE
API
TASK TASK CLUSTER ADMINISTRATION
LOAD ECS
BALANCER AGENT KEY/VALUE STORAGE
Container Container
25
Amazon ECS – Cluster
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK Amazon
ECS
AGENT ECS
Container Container COMMUNICATION SERVICE
API
TASK TASK CLUSTER ADMINISTRATION
LOAD ECS
BALANCER AGENT KEY/VALUE STORAGE
Container Container
26
Amazon ECS – Task
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK Amazon
ECS
AGENT ECS
Container Container COMMUNICATION SERVICE
API
TASK TASK CLUSTER ADMINISTRATION
LOAD ECS
BALANCER AGENT KEY/VALUE STORAGE
Container Container
27
Tasks
• Work Unit
• Group of containers
• Execute inside a container instance / EC2
28
Amazon ECS – Service
EC2 INSTANCES
TASK TASK
LOAD
BALANCER ECS
Internet AGENT
Container Container
TASK TASK Amazon
ECS
AGENT ECS
Container Container COMMUNICATION SERVICE
API
TASK TASK CLUSTER ADMINISTRATION
LOAD ECS
BALANCER AGENT KEY/VALUE STORAGE
Container Container
29
Create a Service
Load balancing between containers
Automatic failover in case of failure
Scale out and scale in
Elastic Load Balancing
Shared Data Volume Shared Data Volume Shared Data Volume
Containers Containers Containers
Container A Container A Container B
Container B Container C Container C
30
AWS Fargate
Without Fargate, you end up managing more than just containers
EC2 Instance
Docker ECS
OS
Agent Agent
33
AWS Fargate
- Patching and Upgrading OS, agents, etc.
- Scaling the instance fleet for optimal utilization
34
Amazon Elastic Container Service
AWS Fargate
run serverless containers
35
AWS Fargate
Managed by AWS
No EC2 Instances to provision, scale or manage
Elastic
Scale up & down seamlessly. Pay only for what you use
Your
containerized
applications
Integrated
with the AWS ecosystem: VPC Networking, Elastic Load
Balancing, IAM Permissions, CloudWatch and more
36
Networking
VPC INTEGRATION
172.31.0.0/16
• AWS VPC Networking Mode – each task gets
its own interface
Subnet
172.31.1.0/24
• All Fargate Tasks run in customer VPC and
subnets
Internet
ENI Fargate
Public / Private IP Task
• Configure security groups to control inbound208.57.73.13 / 172.31.1.164
& outbound traffic
Other Entities in VPC
• Public IP support
EC2 LB DB etc.
• Spread your application across subnets in
multiple Availability Zones (AZs) for
resiliency
Microservices DevOps
Monolith development lifecycle
developers services
delivery pipelines
build test release monitor
40
Microservice development lifecycle
developers services
delivery pipelines
build test release monitor
41
Microservice development lifecycle
developers services
delivery pipelines
???
42
Microservice development lifecycle
developers services delivery pipelines
build test release monitor
build test release monitor
build test release monitor
build test release monitor
build test release monitor
build test release monitor
43
Amazon ECS CI/CD
Container CI/CD on AWS ECS - Architecture
AWS Cloud
Region
Application
Amazon ECR Load Balancer
5b
3
1 2 4 5a
Git Push
end users AWS AWS AWS Amazon ECS
CodeCommit CodeBuild CodeDeploy
AWS
CodePipeline
45
Questions?
Lab 3
• Go to https://aws.qwiklabs.com
• Login with your account.
• If you don’t have an account, register and then activate the account using the email that you
will receive.
• Start the Lab 3, and read the instructions.
• If you have doubts about the activity, please ask the trainer to receive help.
• You have 45 minutes to complete this lab.
48