SlideShare a Scribd company logo
1 of 77
Download to read offline
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Apr 21 2016
Amazon EC2 Container
Service Deep Dive
Shiva N, Solution Architect, AWS
Agenda
The Basics
Infrastructure Setup
Infrastructure Management
Deploying Applications
PaaS on ECS
Using the CLI
TaskDefinitions
Containers
Clusters
Container Instances
Key Components
Amazon ECS Infrastructure
Setup
Amazon ECS Infrastructure Setup
Amazon ECS Cluster Setup
Amazon ECR Setup
Amazon ECS Cluster Setup
Amazon ECS Cluster Setup
There are many ways to provision cluster infrastructure
v AWS – CloudFormation, Simple Systems Manager,
Autoscale Groups, OpsWorks, ECS-CLI
v Others - Terraform, PaaS, Partners
Let’s talk about CloudFormation
Cluster Setup with AWS CloudFormation
CloudFormation supports ECS cluster, service and task
definition resources
Use AWS::IAM::Role to create ECS service role and
container instances role
Launch container instances using
AWS:AutoScaling::LaunchConfiguation and
AWS:AutoScaling::AutoScalingGroup
Cluster Setup with AWS CloudFormation
"Resources" : {
"ECSCluster": {
"Type": "AWS::ECS::Cluster"
},
"ECSAutoScalingGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"VPCZoneIdentifier" : { "Ref" : "SubnetID" },
"LaunchConfigurationName" : { "Ref" : "ContainerInstances" },
"MinSize" : "1",
"MaxSize" : { "Ref" : "MaxSize" },
"DesiredCapacity" : { "Ref" : "DesiredCapacity" }
},
[…]
},
Cluster Setup with AWS CloudFormation
"ContainerInstances": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"commands" : {
"01_add_instance_to_cluster" : {
"command" : { "Fn::Join": [ "", [ "#!/bin/bashn", "echo
ECS_CLUSTER=", { "Ref": "ECSCluster" }, " >> /etc/ecs/ecs.config" ] ] }
}
},
[…]
}
}
}
Amazon ECR Setup
Amazon ECR Setup
You have read and write access to the repositories you
create in your default registry, i.e.
<aws_account_id>.dkr.ecr.us-east-1.amazonaws.com
Repository names can support namespaces, e.g. team-
a/web-app.
Repositories can be controlled with both IAM user access
policies and repository policies.
Amazon ECR Setup
# Authenticate Docker to your Amazon ECR registry
> aws ecr get-login
docker login -u AWS -p <password> -e none https://<aws_account_id>.dkr.ecr.us-east-
1.amazonaws.com
> docker login -u AWS -p <password> -e none https://<aws_account_id>.dkr.ecr.us-east-
1.amazonaws.com
# Create a repository called ecr-demo
> aws ecr create-repository --repository-name ecr-demo
# Push an image to your repository
> docker push <aws_account_id>.dkr.ecr.us-east-1.amazonaws.com/ecr-demo:v1
Amazon ECS Infrastructure
Management
Amazon ECS Infrastructure Management
Monitoring & Logging
Scaling ECS
Service Discovery & Configuration Management
Security
Monitoring & Logging
Monitoring and Logging on Amazon ECS
Monitoring with Amazon CloudWatch
Configuring logging in Task Definition
Amazon CloudTrail
Monitoring Amazon ECS with Datadog
Monitoring Amazon ECS with Sysdig Cloud
Monitoring with Amazon CloudWatch
Metric data sent to CloudWatch in 1-minute periods and
recorded for a period of two weeks
Available metrics: CPUReservation, MemoryReservation,
CPUUtilization, MemoryUtilization
Available dimensions: ClusterName, ServiceName
Monitoring with Amazon CloudWatch
Monitoring with Amazon CloudWatch
Use the Amazon CloudWatch Monitoring Scripts to monitor
additional metrics, e.g. disk space:
# Edit crontab
> crontab -e
# Add command to report disk space utilization to CloudWatch every five minutes
*/5 * * * * <path_to>/mon-put-instance-data.pl --disk-space-util --disk-space-used --disk-
space-avail --disk-path=/ --from-cron
Configuring Logging in Task Definition
logConfiguration task definition parameter
Requires version 1.18 or greater of the Docker Remote API
Maps to docker run --log-driver option
Log drivers: json-file, syslog, journald, gelf, fluentd
Logging with Amazon CloudWatch Logs
• Logging container with syslogd
and CloudWatch Logs Agent
• Attach /var/log Volume to
Logging container (Sidecar
pattern)
• Link other containers
syslogd
CloudWatch Logs
Agent
CloudWatch
Logs
Container instance
ECS Cluster
ECS Agent
Logs
Docker
Logs
Logging Amazon ECS API with AWS CloudTrail
{
"eventVersion": "1.03",
"userIdentity": {…},
"eventTime": "2015-10-12T13:57:33Z",
"eventSource": "ecs.amazonaws.com",
"eventName": "CreateCluster",
"awsRegion": "eu-west-1",
"sourceIPAddress": "54.240.197.227",
"userAgent": "console.amazonaws.com",
"requestParameters": {
"clusterName": "ecs-cli"
},
Logging Amazon ECS API with AWS CloudTrail
"responseElements": {
"cluster": {
"clusterArn": "arn:aws:ecs:eu-west-
1:560846014933:cluster/ecs-cli",
"pendingTasksCount": 0,
"registeredContainerInstancesCount": 0,
"status": "ACTIVE",
"runningTasksCount": 0,
"clusterName": "ecs-cli",
"activeServicesCount": 0
}
},
[…]
Monitoring Amazon ECS with Datadog
Monitoring Amazon ECS with Sysdig Cloud
Scaling Amazon ECS
Scaling Amazon ECS
AutoScaling your Amazon ECS cluster
Scaling your Services with Lambda
Setup ECS Cluster with AutoScaling
Create LaunchConfiguration
• Pick instance type
depending on resource
requirements, e.g. memory
or CPU
• Use latest Amazon Linux
ECS-optimized AMI, other
distros available
Create AutoScaling group and
set to cluster initial size
AutoScaling your Amazon ECS Cluster
• Create CloudWatch
alarm on a metric, e.g.
MemoryReservation
• Configure scaling
policies to increase and
decrease the size of your
cluster
Scaling your Services with Lambda
• Cloudwatch metrics tied
to SNS
• SNS triggers Lambda
Container Scaling
function
• Lambda scales task
count on cluster
• Bonus - Extensible
‘cluster intelligence’ layer
Service Discovery &
Configuration Management
Service Discovery on Amazon ECS
Service Discovery with ECS Services & Route 53
Service Discovery with Weaveworks
Service Discovery and Configuration Management with
Consul
Service Discovery and Configuration Management with
etcd
Service Discovery with ECS Services & Route 53
• Route 53 private hosted zone
• Set search path on hosts with DHCP option sets
• Define ECS services with ELB
• Create CNAMEs for each ELB
Service Discovery with ECS Services & Route 53
Task
Task TaskTask
ECS
Service
Application
router, e.g.
nginx
Internal ELB with
CNAME, e.g.
api.example.com
Route 53
private zone,
e.g.
example.com
Service Discovery with Weaveworks
DNS interface for cross-host
container communication
Gossip protocol to share
grouped updates
Overlay network between hosts
Service Discovery and Configuration
Management with Consul
Three main components:
• Consul agent - Runs on each node, responsible for
checking the health of the services and of the node
itself.
• One or more Consul servers - Store and replicate
data, leader elected using the Raft consensus
algorithm
• Registrator agent - Automatically
register/deregisters services based on published
ports and metadata from the container environment
variables defined in the ECS task definition
Service Discovery and Configuration
Management with Consul
ECSCluster
consul-server
ECS Instance
consul-agent
registrator
ECS Instance
Back end 1
Back end 2
consul-agent
registrator
ECS Instance
Front end
ECSCluster
Service Discovery and Configuration
Management with etcd
etcd
registrator
ECS Instance
Container 1
Container 2
confd etcd
registrator
ECS Instance
Container 1
Container 2
confd etcd
registrator
ECS Instance
Container 1
Container 2
confd
Security
Security
ECS IAM Policies and Roles
ECR IAM Policies and Roles
Image Vulnerability Scanning with Twistlock
ECS IAM Policies and Roles
The ECS agent calls the ECS APIs on your behalf, so
container instances require an IAM policy and role that
allows these calls.
The ECS service scheduler calls the EC2 and ELB APIs on
your behalf to register and deregister container instances
with your load balancers.
Use AmazonEC2ContainerServiceforEC2Role and
AmazonEC2ContainerServiceRole managed policies
(respectively)
ECR IAM Policies and Roles
ECR uses resource-based permissions to control access.
By default, only the repository owner has access to a
repository.
You can apply a policy document that allows others to
access your repository.
Use managed policies for IAM users or roles that allow
differing levels of control:
AmazonEC2ContainerRegistryFullAccess,
AmazonEC2ContainerRegistryPowerUser or
AmazonEC2ContainerRegistryReadOnly
Image Vulnerability Scanning with Twistlock
Deploying Applications
Deploying Applications
Scheduling Containers
Automating Deployments
Scheduling Containers
Scheduling Containers on ECS
Batch Jobs
ECS Task scheduler
Run tasks once
Batch jobs
RunTask (random)
StartTask (placed)
Long-Running Apps
ECS Service scheduler
Health management
Scale-up and scale-down
AZ aware
Grouped Containers
Scheduling Containers: Long-running App
Optionally run your service behind a load balancer.
One load balancer per service.
ELB currently supports a fixed relationship between the
load balancer port and the container instance port.
If a task fails the ELB health check, the task is killed and
restarted (until service reaches desired capacity).
Scheduling Containers: Long-running App
Update service’s task definition (rolling update)
Specify a deployment configuration for your service:
• minimumHealthyPercent: lower limit (as a percentage of
the service's desiredCount) of the number of running
tasks that must remain running in a service during a
deployment.
• maximumPercent: upper limit (as a percentage of the
service's desiredCount) of the number of running tasks
that can be running in a service during a deployment.
Scheduling Containers: Long-running app
Deploy using the least space: minimumHealthyPercent =
50%, maximumPercent = 100%
Scheduling Containers: Long-running App
Deploy quickly without reducing service capacity:
minimumHealthyPercent = 100%, maximumPercent =
200%
Scheduling Containers: Long-running App
Blue-Green Deployments
• Define two ECS services
• Each service is associated w/ ELB
• Both ELBs in Route 53 record set
with weighted routing policy, 100%
Primary, 0% Secondary
• Deploy to Blue or Green service and
switch weights
TaskTask
Route 53
record set
with
weighted
routing
policy
0%
100%
Automating Deployments
Automating Deployments
Continuous Delivery to ECS with Jenkins
Continuous Delivery to ECS with Shippable
Continuous Delivery to ECS with Jenkins
4. Push image to
Docker registry
2. Build image
from sources
3. Run test on image
1. Code push
triggers build
5. Update Service
6. Pull image
Continuous Delivery to ECS with Jenkins
Easy Deployment
Developers – Merge into master, done!
Jenkins Build Steps
Trigger via Webhooks, Monitoring, Lambda
Build Docker image via Build and Publish plugin
Push Docker image into Registry
Register Updated Job with ECS API
Continuous Delivery to ECS with Shippable
ECS CI/CD Partners
PaaS on ECS
PaaS on ECS
AWS Elastic Beanstalk
Convox
Remind Empire
AWS Elastic Beanstalk
Uses Amazon ECS to coordinate deployments to
multicontainer Docker environments
Takes care of tasks including cluster creation, task
definition and execution
AWS Elastic Beanstalk
Elastic Beanstalk uses a Dockerrun.aws.json file that
describes how to deploy containers.
The Dockerrun.aws.json file includes three sections:
• AWSEBDockerrunVersion: Set to "2" for multicontainer
Docker environments.
• containerDefinitions: An array of container definitions.
• volumes: Creates mount points in the container instance
that a container can use.
Convox
Convox
# Initialize your app and create default manifest
> convox init
# Locally build and run your app as declared in the manifest
> convox start
# Create app
> convox apps create my_app
# Deploy app, output ELB DNS name
> convox deploy
[...]
web: http://my_app-1234567890.us-east-1.elb.amazonaws.com
Remind Empire
Control layer on top of Amazon ECS that provides a
Heroku like workflow
Any tagged Docker image can be deployed to Empire as
an app
• When you deploy a Docker image to Empire, it will
extract a Procfile from the WORKDIR
• Each process type in the Procfile maps directly to an
ECS Service
Remind Empire
Routing layer backed by internal ELBs
• An application that specifies a web process will get an
internal ELB attached to its ECS Service
• When a new internal ELB is created, an associated
CNAME record is created in Route53 under the internal
TLD, enabling service discovery via DNS
Using the CLI
Using the CLI
Configuring the ECS CLI
Cluster Setup with the ECS CLI
Deploy Compose App with ECS CLI
Scaling with ECS CLI
Configuring the ECS CLI
Easily create Amazon ECS clusters & supporting
resources such as EC2 instances
Run Docker Compose configuration files on Amazon
ECS
Available today – http://amzn.to/1jBf45a
Configuring the ECS CLI
# Configure the CLI using environment variables
> export AWS_ACCESS_KEY_ID=<my_access_key>
> export AWS_SECRET_ACCESS_KEY=<my_secret_key>
> ecs-cli configure --region us-east-1 --access-key
$AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --cluster
ecs-cli-demo
# Configure the CLI using an existing AWS CLI profile
> ecs-cli configure --region us-west-2 --profile ecs-profile --
cluster ecs-cli-demo
Cluster Setup with the ECS CLI
# Creates a new ECS cluster with two container instances in an
existing VPC
> ecs-cli up --capability-iam --keypair my_ecs_keypair --size 2 -
-security-group sg-a12bc34d --vpc vpc-0e9dc8b7 --subnets subnet-
12ab34cd,subnet-56ef78ab --instance-type t2.medium
# Creates a new ECS cluster with one container instance in a new
VPC
> ecs-cli up --capability-iam --keypair my_ecs_keypair --azs us-
east-1a,us-east-1c --cidr 192.169.0.0/24 --port 22 --instance-
type t2.medium
Deploy Compose App with ECS CLI
Docker Compose lets you define and run multi-container
applications:
1. Define app environment with Dockerfile
2. Define services that make up your app in docker-
compose.yml
3. Run docker-compose up to start and run entire app
Deploy Compose App with ECS CLI
proxy:
build: ./proxy
ports:
- "80:80"
links:
- web
web:
build: ./web
command: bundle exec rails server -b 0.0.0.0
environment:
- SECRET_KEY_BASE=secretkey
expose:
- "3000"
Deploy Compose App with ECS CLI
> ecs-cli compose up
> ecs-cli compose ps
> ecs-cli compose service create
> ecs-cli compose service start
Scaling with ECS CLI
> ecs-cli scale n
> ecs-cli compose scale n
> ecs-cli compose service scale n
Thank you!

More Related Content

What's hot

Getting Started with Docker on AWS - DevDay Austin 2017
Getting Started with Docker on AWS - DevDay Austin 2017Getting Started with Docker on AWS - DevDay Austin 2017
Getting Started with Docker on AWS - DevDay Austin 2017
Amazon Web Services
 
Intro to Batch Processing on AWS - DevDay Austin 2017
Intro to Batch Processing on AWS - DevDay Austin 2017Intro to Batch Processing on AWS - DevDay Austin 2017
Intro to Batch Processing on AWS - DevDay Austin 2017
Amazon Web Services
 
Building a CICD Pipeline for Containers - DevDay Austin 2017
Building a CICD Pipeline for Containers - DevDay Austin 2017Building a CICD Pipeline for Containers - DevDay Austin 2017
Building a CICD Pipeline for Containers - DevDay Austin 2017
Amazon Web Services
 
Building and Scaling a Containerized Microservice - DevDay Austin 2017
Building and Scaling a Containerized Microservice - DevDay Austin 2017Building and Scaling a Containerized Microservice - DevDay Austin 2017
Building and Scaling a Containerized Microservice - DevDay Austin 2017
Amazon Web Services
 

What's hot (20)

Amazon ECS Deep Dive
Amazon ECS Deep DiveAmazon ECS Deep Dive
Amazon ECS Deep Dive
 
(CMP302) Amazon ECS: Distributed Applications at Scale
(CMP302) Amazon ECS: Distributed Applications at Scale(CMP302) Amazon ECS: Distributed Applications at Scale
(CMP302) Amazon ECS: Distributed Applications at Scale
 
Getting Started with Docker on AWS - DevDay Austin 2017
Getting Started with Docker on AWS - DevDay Austin 2017Getting Started with Docker on AWS - DevDay Austin 2017
Getting Started with Docker on AWS - DevDay Austin 2017
 
Intro to Batch Processing on AWS - DevDay Austin 2017
Intro to Batch Processing on AWS - DevDay Austin 2017Intro to Batch Processing on AWS - DevDay Austin 2017
Intro to Batch Processing on AWS - DevDay Austin 2017
 
Getting Started with Docker on AWS - DevDay Los Angeles 2017
Getting Started with Docker on AWS - DevDay Los Angeles 2017Getting Started with Docker on AWS - DevDay Los Angeles 2017
Getting Started with Docker on AWS - DevDay Los Angeles 2017
 
Building a CICD Pipeline for Deploying to Containers
Building a CICD Pipeline for Deploying to ContainersBuilding a CICD Pipeline for Deploying to Containers
Building a CICD Pipeline for Deploying to Containers
 
Continuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container ServiceContinuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container Service
 
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
 
Building a CICD Pipeline for Containers - DevDay Austin 2017
Building a CICD Pipeline for Containers - DevDay Austin 2017Building a CICD Pipeline for Containers - DevDay Austin 2017
Building a CICD Pipeline for Containers - DevDay Austin 2017
 
Amazon ECS Deep Dive
Amazon ECS Deep DiveAmazon ECS Deep Dive
Amazon ECS Deep Dive
 
Intro to Amazon ECS
Intro to Amazon ECSIntro to Amazon ECS
Intro to Amazon ECS
 
Workshop: Serverless DevOps to the Rescue
Workshop: Serverless DevOps to the RescueWorkshop: Serverless DevOps to the Rescue
Workshop: Serverless DevOps to the Rescue
 
Continuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container ServiceContinuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container Service
 
Advanced Container Management and Scheduling
Advanced Container Management and SchedulingAdvanced Container Management and Scheduling
Advanced Container Management and Scheduling
 
Getting Started with Docker on AWS
Getting Started with Docker on AWSGetting Started with Docker on AWS
Getting Started with Docker on AWS
 
Containers State of the Union
Containers State of the UnionContainers State of the Union
Containers State of the Union
 
Micrsoservices unleashed with containers and ECS
Micrsoservices unleashed with containers and ECSMicrsoservices unleashed with containers and ECS
Micrsoservices unleashed with containers and ECS
 
Amazon Web Services EC2 Container Service (ECS)
Amazon Web Services EC2 Container Service (ECS)Amazon Web Services EC2 Container Service (ECS)
Amazon Web Services EC2 Container Service (ECS)
 
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
 
Building and Scaling a Containerized Microservice - DevDay Austin 2017
Building and Scaling a Containerized Microservice - DevDay Austin 2017Building and Scaling a Containerized Microservice - DevDay Austin 2017
Building and Scaling a Containerized Microservice - DevDay Austin 2017
 

Viewers also liked

The standard container securing
The standard container securingThe standard container securing
The standard container securing
Luis Vitiritti
 

Viewers also liked (20)

Your APIs can be soft and fluffy
Your APIs can be soft and fluffyYour APIs can be soft and fluffy
Your APIs can be soft and fluffy
 
Leveraging Elastic Web Scale Computing with AWS
 Leveraging Elastic Web Scale Computing with AWS Leveraging Elastic Web Scale Computing with AWS
Leveraging Elastic Web Scale Computing with AWS
 
Application Delivery Patterns
Application Delivery PatternsApplication Delivery Patterns
Application Delivery Patterns
 
AWS ECS Quick Introduction
AWS ECS Quick IntroductionAWS ECS Quick Introduction
AWS ECS Quick Introduction
 
Build high performing mobile apps, faster with AWS
Build high performing mobile apps, faster with AWSBuild high performing mobile apps, faster with AWS
Build high performing mobile apps, faster with AWS
 
Platform for Innovation - AWS
Platform for Innovation - AWSPlatform for Innovation - AWS
Platform for Innovation - AWS
 
Deep Dive into AWS ECS and Spot Instances at Scale
Deep Dive into AWS ECS and Spot Instances at ScaleDeep Dive into AWS ECS and Spot Instances at Scale
Deep Dive into AWS ECS and Spot Instances at Scale
 
Event driven infrastructure
Event driven infrastructureEvent driven infrastructure
Event driven infrastructure
 
Innovation at Scale - Top 10 AWS questions when you start
Innovation at Scale - Top 10 AWS questions when you startInnovation at Scale - Top 10 AWS questions when you start
Innovation at Scale - Top 10 AWS questions when you start
 
February 2016 Webinar Series - EC2 Container Service Deep Dive
February 2016 Webinar Series - EC2 Container Service Deep Dive February 2016 Webinar Series - EC2 Container Service Deep Dive
February 2016 Webinar Series - EC2 Container Service Deep Dive
 
Deep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECSDeep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECS
 
AWS re:Invent 2016: Infrastructure Continuous Delivery Using AWS CloudFormati...
AWS re:Invent 2016: Infrastructure Continuous Delivery Using AWS CloudFormati...AWS re:Invent 2016: Infrastructure Continuous Delivery Using AWS CloudFormati...
AWS re:Invent 2016: Infrastructure Continuous Delivery Using AWS CloudFormati...
 
AWS Tagging Strategy
AWS Tagging StrategyAWS Tagging Strategy
AWS Tagging Strategy
 
TerraformでECS+ECRする話
TerraformでECS+ECRする話TerraformでECS+ECRする話
TerraformでECS+ECRする話
 
The standard container securing
The standard container securingThe standard container securing
The standard container securing
 
AWS Security and SecOps
AWS Security and SecOpsAWS Security and SecOps
AWS Security and SecOps
 
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS Lambda
 
AWS Lambda and Serverless Cloud
AWS Lambda and Serverless CloudAWS Lambda and Serverless Cloud
AWS Lambda and Serverless Cloud
 
AWS re:Invent 2016: Introduction to Container Management on AWS (CON303)
AWS re:Invent 2016: Introduction to Container Management on AWS (CON303)AWS re:Invent 2016: Introduction to Container Management on AWS (CON303)
AWS re:Invent 2016: Introduction to Container Management on AWS (CON303)
 

Similar to ECS and ECR deep dive

Similar to ECS and ECR deep dive (20)

Monitoring Containers at Scale - September Webinar Series
Monitoring Containers at Scale - September Webinar SeriesMonitoring Containers at Scale - September Webinar Series
Monitoring Containers at Scale - September Webinar Series
 
Weaveworks at AWS re:Invent 2016: Operations Management with Amazon ECS
Weaveworks at AWS re:Invent 2016: Operations Management with Amazon ECSWeaveworks at AWS re:Invent 2016: Operations Management with Amazon ECS
Weaveworks at AWS re:Invent 2016: Operations Management with Amazon ECS
 
Amazon EC2 container service
Amazon EC2 container serviceAmazon EC2 container service
Amazon EC2 container service
 
Docker clusters on AWS with Amazon ECS and Kubernetes
Docker clusters on AWS with Amazon ECS and KubernetesDocker clusters on AWS with Amazon ECS and Kubernetes
Docker clusters on AWS with Amazon ECS and Kubernetes
 
Amazon ECS.pptx tasks conatiner ecs new car
Amazon ECS.pptx tasks conatiner ecs new carAmazon ECS.pptx tasks conatiner ecs new car
Amazon ECS.pptx tasks conatiner ecs new car
 
Getting Started with Serverless and Container Architectures
Getting Started with Serverless and Container ArchitecturesGetting Started with Serverless and Container Architectures
Getting Started with Serverless and Container Architectures
 
Advanced Task Scheduling with Amazon ECS
Advanced Task Scheduling with Amazon ECSAdvanced Task Scheduling with Amazon ECS
Advanced Task Scheduling with Amazon ECS
 
Scheduling Containers on Amazon ECS
Scheduling Containers on Amazon ECSScheduling Containers on Amazon ECS
Scheduling Containers on Amazon ECS
 
Advanced container management and scheduling
Advanced container management and schedulingAdvanced container management and scheduling
Advanced container management and scheduling
 
intro elastic container service amazon aws
intro elastic container service amazon awsintro elastic container service amazon aws
intro elastic container service amazon aws
 
Advanced Container Management and Scheduling - DevDay Los Angeles 2017
Advanced Container Management and Scheduling - DevDay Los Angeles 2017Advanced Container Management and Scheduling - DevDay Los Angeles 2017
Advanced Container Management and Scheduling - DevDay Los Angeles 2017
 
ECS - from 0 to 100
ECS - from 0 to 100ECS - from 0 to 100
ECS - from 0 to 100
 
AWS Elastic Container Service (ECS) with a CI Pipeline Overview
AWS Elastic Container Service (ECS) with a CI Pipeline OverviewAWS Elastic Container Service (ECS) with a CI Pipeline Overview
AWS Elastic Container Service (ECS) with a CI Pipeline Overview
 
AWS ECS Meetup Talentica
AWS ECS Meetup TalenticaAWS ECS Meetup Talentica
AWS ECS Meetup Talentica
 
Amazon EKS Deep Dive
Amazon EKS Deep DiveAmazon EKS Deep Dive
Amazon EKS Deep Dive
 
應用開發新思維
應用開發新思維應用開發新思維
應用開發新思維
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
 
Microservices and Amazon ECS
Microservices and Amazon ECSMicroservices and Amazon ECS
Microservices and Amazon ECS
 
Advanced Scheduling with Amazon ECS (September 2017)
Advanced Scheduling with Amazon ECS (September 2017)Advanced Scheduling with Amazon ECS (September 2017)
Advanced Scheduling with Amazon ECS (September 2017)
 
Getting Started with Amazon EC2 Container Service
Getting Started with Amazon EC2 Container ServiceGetting Started with Amazon EC2 Container Service
Getting Started with Amazon EC2 Container Service
 

More from Shiva Narayanaswamy

More from Shiva Narayanaswamy (13)

State of Union - Containerz
State of Union - ContainerzState of Union - Containerz
State of Union - Containerz
 
Pets, Cattle, Rabbits and Microbes
Pets, Cattle, Rabbits and Microbes Pets, Cattle, Rabbits and Microbes
Pets, Cattle, Rabbits and Microbes
 
AWS + Puppet = Dynamic Scale
AWS + Puppet = Dynamic ScaleAWS + Puppet = Dynamic Scale
AWS + Puppet = Dynamic Scale
 
DevOps and AWS
DevOps and AWSDevOps and AWS
DevOps and AWS
 
AWS Connectivity, VPC Design and Security Pro Tips
AWS Connectivity, VPC Design and Security Pro TipsAWS Connectivity, VPC Design and Security Pro Tips
AWS Connectivity, VPC Design and Security Pro Tips
 
Dev/Test Environment Provisioning and Management on AWS
Dev/Test Environment Provisioning and Management on AWSDev/Test Environment Provisioning and Management on AWS
Dev/Test Environment Provisioning and Management on AWS
 
DevOps, Common use cases, Architectures, Best Practices
DevOps, Common use cases, Architectures, Best PracticesDevOps, Common use cases, Architectures, Best Practices
DevOps, Common use cases, Architectures, Best Practices
 
Application Lifecycle Management and Event Driven Programming on AWS
Application Lifecycle Management and Event Driven Programming on AWSApplication Lifecycle Management and Event Driven Programming on AWS
Application Lifecycle Management and Event Driven Programming on AWS
 
Leveraging elastic web scale computing with AWS
 Leveraging elastic web scale computing with AWS Leveraging elastic web scale computing with AWS
Leveraging elastic web scale computing with AWS
 
Running Hybrid Cloud Patterns on AWS
Running Hybrid Cloud Patterns on AWSRunning Hybrid Cloud Patterns on AWS
Running Hybrid Cloud Patterns on AWS
 
AWS EC2 and ELB troubleshooting
AWS EC2 and ELB troubleshootingAWS EC2 and ELB troubleshooting
AWS EC2 and ELB troubleshooting
 
Continuous delivery and deployment on AWS
Continuous delivery and deployment on AWSContinuous delivery and deployment on AWS
Continuous delivery and deployment on AWS
 
Introduction to DevOps on AWS
Introduction to DevOps on AWSIntroduction to DevOps on AWS
Introduction to DevOps on AWS
 

Recently uploaded

6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
Diya Sharma
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 

Recently uploaded (20)

'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 

ECS and ECR deep dive

  • 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Apr 21 2016 Amazon EC2 Container Service Deep Dive Shiva N, Solution Architect, AWS
  • 2. Agenda The Basics Infrastructure Setup Infrastructure Management Deploying Applications PaaS on ECS Using the CLI
  • 5. Amazon ECS Infrastructure Setup Amazon ECS Cluster Setup Amazon ECR Setup
  • 7. Amazon ECS Cluster Setup There are many ways to provision cluster infrastructure v AWS – CloudFormation, Simple Systems Manager, Autoscale Groups, OpsWorks, ECS-CLI v Others - Terraform, PaaS, Partners Let’s talk about CloudFormation
  • 8. Cluster Setup with AWS CloudFormation CloudFormation supports ECS cluster, service and task definition resources Use AWS::IAM::Role to create ECS service role and container instances role Launch container instances using AWS:AutoScaling::LaunchConfiguation and AWS:AutoScaling::AutoScalingGroup
  • 9. Cluster Setup with AWS CloudFormation "Resources" : { "ECSCluster": { "Type": "AWS::ECS::Cluster" }, "ECSAutoScalingGroup" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "VPCZoneIdentifier" : { "Ref" : "SubnetID" }, "LaunchConfigurationName" : { "Ref" : "ContainerInstances" }, "MinSize" : "1", "MaxSize" : { "Ref" : "MaxSize" }, "DesiredCapacity" : { "Ref" : "DesiredCapacity" } }, […] },
  • 10. Cluster Setup with AWS CloudFormation "ContainerInstances": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "commands" : { "01_add_instance_to_cluster" : { "command" : { "Fn::Join": [ "", [ "#!/bin/bashn", "echo ECS_CLUSTER=", { "Ref": "ECSCluster" }, " >> /etc/ecs/ecs.config" ] ] } } }, […] } } }
  • 12. Amazon ECR Setup You have read and write access to the repositories you create in your default registry, i.e. <aws_account_id>.dkr.ecr.us-east-1.amazonaws.com Repository names can support namespaces, e.g. team- a/web-app. Repositories can be controlled with both IAM user access policies and repository policies.
  • 13. Amazon ECR Setup # Authenticate Docker to your Amazon ECR registry > aws ecr get-login docker login -u AWS -p <password> -e none https://<aws_account_id>.dkr.ecr.us-east- 1.amazonaws.com > docker login -u AWS -p <password> -e none https://<aws_account_id>.dkr.ecr.us-east- 1.amazonaws.com # Create a repository called ecr-demo > aws ecr create-repository --repository-name ecr-demo # Push an image to your repository > docker push <aws_account_id>.dkr.ecr.us-east-1.amazonaws.com/ecr-demo:v1
  • 15. Amazon ECS Infrastructure Management Monitoring & Logging Scaling ECS Service Discovery & Configuration Management Security
  • 17. Monitoring and Logging on Amazon ECS Monitoring with Amazon CloudWatch Configuring logging in Task Definition Amazon CloudTrail Monitoring Amazon ECS with Datadog Monitoring Amazon ECS with Sysdig Cloud
  • 18. Monitoring with Amazon CloudWatch Metric data sent to CloudWatch in 1-minute periods and recorded for a period of two weeks Available metrics: CPUReservation, MemoryReservation, CPUUtilization, MemoryUtilization Available dimensions: ClusterName, ServiceName
  • 20. Monitoring with Amazon CloudWatch Use the Amazon CloudWatch Monitoring Scripts to monitor additional metrics, e.g. disk space: # Edit crontab > crontab -e # Add command to report disk space utilization to CloudWatch every five minutes */5 * * * * <path_to>/mon-put-instance-data.pl --disk-space-util --disk-space-used --disk- space-avail --disk-path=/ --from-cron
  • 21. Configuring Logging in Task Definition logConfiguration task definition parameter Requires version 1.18 or greater of the Docker Remote API Maps to docker run --log-driver option Log drivers: json-file, syslog, journald, gelf, fluentd
  • 22. Logging with Amazon CloudWatch Logs • Logging container with syslogd and CloudWatch Logs Agent • Attach /var/log Volume to Logging container (Sidecar pattern) • Link other containers syslogd CloudWatch Logs Agent CloudWatch Logs Container instance ECS Cluster ECS Agent Logs Docker Logs
  • 23. Logging Amazon ECS API with AWS CloudTrail { "eventVersion": "1.03", "userIdentity": {…}, "eventTime": "2015-10-12T13:57:33Z", "eventSource": "ecs.amazonaws.com", "eventName": "CreateCluster", "awsRegion": "eu-west-1", "sourceIPAddress": "54.240.197.227", "userAgent": "console.amazonaws.com", "requestParameters": { "clusterName": "ecs-cli" },
  • 24. Logging Amazon ECS API with AWS CloudTrail "responseElements": { "cluster": { "clusterArn": "arn:aws:ecs:eu-west- 1:560846014933:cluster/ecs-cli", "pendingTasksCount": 0, "registeredContainerInstancesCount": 0, "status": "ACTIVE", "runningTasksCount": 0, "clusterName": "ecs-cli", "activeServicesCount": 0 } }, […]
  • 25. Monitoring Amazon ECS with Datadog
  • 26. Monitoring Amazon ECS with Sysdig Cloud
  • 28. Scaling Amazon ECS AutoScaling your Amazon ECS cluster Scaling your Services with Lambda
  • 29. Setup ECS Cluster with AutoScaling Create LaunchConfiguration • Pick instance type depending on resource requirements, e.g. memory or CPU • Use latest Amazon Linux ECS-optimized AMI, other distros available Create AutoScaling group and set to cluster initial size
  • 30. AutoScaling your Amazon ECS Cluster • Create CloudWatch alarm on a metric, e.g. MemoryReservation • Configure scaling policies to increase and decrease the size of your cluster
  • 31. Scaling your Services with Lambda • Cloudwatch metrics tied to SNS • SNS triggers Lambda Container Scaling function • Lambda scales task count on cluster • Bonus - Extensible ‘cluster intelligence’ layer
  • 33. Service Discovery on Amazon ECS Service Discovery with ECS Services & Route 53 Service Discovery with Weaveworks Service Discovery and Configuration Management with Consul Service Discovery and Configuration Management with etcd
  • 34. Service Discovery with ECS Services & Route 53 • Route 53 private hosted zone • Set search path on hosts with DHCP option sets • Define ECS services with ELB • Create CNAMEs for each ELB
  • 35. Service Discovery with ECS Services & Route 53 Task Task TaskTask ECS Service Application router, e.g. nginx Internal ELB with CNAME, e.g. api.example.com Route 53 private zone, e.g. example.com
  • 36. Service Discovery with Weaveworks DNS interface for cross-host container communication Gossip protocol to share grouped updates Overlay network between hosts
  • 37. Service Discovery and Configuration Management with Consul Three main components: • Consul agent - Runs on each node, responsible for checking the health of the services and of the node itself. • One or more Consul servers - Store and replicate data, leader elected using the Raft consensus algorithm • Registrator agent - Automatically register/deregisters services based on published ports and metadata from the container environment variables defined in the ECS task definition
  • 38. Service Discovery and Configuration Management with Consul ECSCluster consul-server ECS Instance consul-agent registrator ECS Instance Back end 1 Back end 2 consul-agent registrator ECS Instance Front end ECSCluster
  • 39. Service Discovery and Configuration Management with etcd etcd registrator ECS Instance Container 1 Container 2 confd etcd registrator ECS Instance Container 1 Container 2 confd etcd registrator ECS Instance Container 1 Container 2 confd
  • 41. Security ECS IAM Policies and Roles ECR IAM Policies and Roles Image Vulnerability Scanning with Twistlock
  • 42. ECS IAM Policies and Roles The ECS agent calls the ECS APIs on your behalf, so container instances require an IAM policy and role that allows these calls. The ECS service scheduler calls the EC2 and ELB APIs on your behalf to register and deregister container instances with your load balancers. Use AmazonEC2ContainerServiceforEC2Role and AmazonEC2ContainerServiceRole managed policies (respectively)
  • 43. ECR IAM Policies and Roles ECR uses resource-based permissions to control access. By default, only the repository owner has access to a repository. You can apply a policy document that allows others to access your repository. Use managed policies for IAM users or roles that allow differing levels of control: AmazonEC2ContainerRegistryFullAccess, AmazonEC2ContainerRegistryPowerUser or AmazonEC2ContainerRegistryReadOnly
  • 48. Scheduling Containers on ECS Batch Jobs ECS Task scheduler Run tasks once Batch jobs RunTask (random) StartTask (placed) Long-Running Apps ECS Service scheduler Health management Scale-up and scale-down AZ aware Grouped Containers
  • 49. Scheduling Containers: Long-running App Optionally run your service behind a load balancer. One load balancer per service. ELB currently supports a fixed relationship between the load balancer port and the container instance port. If a task fails the ELB health check, the task is killed and restarted (until service reaches desired capacity).
  • 50. Scheduling Containers: Long-running App Update service’s task definition (rolling update) Specify a deployment configuration for your service: • minimumHealthyPercent: lower limit (as a percentage of the service's desiredCount) of the number of running tasks that must remain running in a service during a deployment. • maximumPercent: upper limit (as a percentage of the service's desiredCount) of the number of running tasks that can be running in a service during a deployment.
  • 51. Scheduling Containers: Long-running app Deploy using the least space: minimumHealthyPercent = 50%, maximumPercent = 100%
  • 52. Scheduling Containers: Long-running App Deploy quickly without reducing service capacity: minimumHealthyPercent = 100%, maximumPercent = 200%
  • 53. Scheduling Containers: Long-running App Blue-Green Deployments • Define two ECS services • Each service is associated w/ ELB • Both ELBs in Route 53 record set with weighted routing policy, 100% Primary, 0% Secondary • Deploy to Blue or Green service and switch weights TaskTask Route 53 record set with weighted routing policy 0% 100%
  • 55. Automating Deployments Continuous Delivery to ECS with Jenkins Continuous Delivery to ECS with Shippable
  • 56. Continuous Delivery to ECS with Jenkins 4. Push image to Docker registry 2. Build image from sources 3. Run test on image 1. Code push triggers build 5. Update Service 6. Pull image
  • 57. Continuous Delivery to ECS with Jenkins Easy Deployment Developers – Merge into master, done! Jenkins Build Steps Trigger via Webhooks, Monitoring, Lambda Build Docker image via Build and Publish plugin Push Docker image into Registry Register Updated Job with ECS API
  • 58. Continuous Delivery to ECS with Shippable
  • 61. PaaS on ECS AWS Elastic Beanstalk Convox Remind Empire
  • 62. AWS Elastic Beanstalk Uses Amazon ECS to coordinate deployments to multicontainer Docker environments Takes care of tasks including cluster creation, task definition and execution
  • 63. AWS Elastic Beanstalk Elastic Beanstalk uses a Dockerrun.aws.json file that describes how to deploy containers. The Dockerrun.aws.json file includes three sections: • AWSEBDockerrunVersion: Set to "2" for multicontainer Docker environments. • containerDefinitions: An array of container definitions. • volumes: Creates mount points in the container instance that a container can use.
  • 65. Convox # Initialize your app and create default manifest > convox init # Locally build and run your app as declared in the manifest > convox start # Create app > convox apps create my_app # Deploy app, output ELB DNS name > convox deploy [...] web: http://my_app-1234567890.us-east-1.elb.amazonaws.com
  • 66. Remind Empire Control layer on top of Amazon ECS that provides a Heroku like workflow Any tagged Docker image can be deployed to Empire as an app • When you deploy a Docker image to Empire, it will extract a Procfile from the WORKDIR • Each process type in the Procfile maps directly to an ECS Service
  • 67. Remind Empire Routing layer backed by internal ELBs • An application that specifies a web process will get an internal ELB attached to its ECS Service • When a new internal ELB is created, an associated CNAME record is created in Route53 under the internal TLD, enabling service discovery via DNS
  • 69. Using the CLI Configuring the ECS CLI Cluster Setup with the ECS CLI Deploy Compose App with ECS CLI Scaling with ECS CLI
  • 70. Configuring the ECS CLI Easily create Amazon ECS clusters & supporting resources such as EC2 instances Run Docker Compose configuration files on Amazon ECS Available today – http://amzn.to/1jBf45a
  • 71. Configuring the ECS CLI # Configure the CLI using environment variables > export AWS_ACCESS_KEY_ID=<my_access_key> > export AWS_SECRET_ACCESS_KEY=<my_secret_key> > ecs-cli configure --region us-east-1 --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --cluster ecs-cli-demo # Configure the CLI using an existing AWS CLI profile > ecs-cli configure --region us-west-2 --profile ecs-profile -- cluster ecs-cli-demo
  • 72. Cluster Setup with the ECS CLI # Creates a new ECS cluster with two container instances in an existing VPC > ecs-cli up --capability-iam --keypair my_ecs_keypair --size 2 - -security-group sg-a12bc34d --vpc vpc-0e9dc8b7 --subnets subnet- 12ab34cd,subnet-56ef78ab --instance-type t2.medium # Creates a new ECS cluster with one container instance in a new VPC > ecs-cli up --capability-iam --keypair my_ecs_keypair --azs us- east-1a,us-east-1c --cidr 192.169.0.0/24 --port 22 --instance- type t2.medium
  • 73. Deploy Compose App with ECS CLI Docker Compose lets you define and run multi-container applications: 1. Define app environment with Dockerfile 2. Define services that make up your app in docker- compose.yml 3. Run docker-compose up to start and run entire app
  • 74. Deploy Compose App with ECS CLI proxy: build: ./proxy ports: - "80:80" links: - web web: build: ./web command: bundle exec rails server -b 0.0.0.0 environment: - SECRET_KEY_BASE=secretkey expose: - "3000"
  • 75. Deploy Compose App with ECS CLI > ecs-cli compose up > ecs-cli compose ps > ecs-cli compose service create > ecs-cli compose service start
  • 76. Scaling with ECS CLI > ecs-cli scale n > ecs-cli compose scale n > ecs-cli compose service scale n