SlideShare uma empresa Scribd logo
1 de 34
Building and scaling your containerized
microservices on Amazon ECS
Abby Fuller, AWS
@abbyfuller
Agenda
• Quick microservices overview
• Let’s talk about ECS
• Some ECS best practices
• Flexible orchestration and ECS
• Container lifecycle with aws-cli
• Questions?
Microservices 101
What are microservices?
“Service-oriented architecture
composed of
loosely coupled elements
that have
bounded contexts”
Adrian Cockcroft (VP of Cloud
Architecture @ AWS, former Cloud
Architect at Netflix)
A few microservices best practices
• Rely on the public API
• Use the right tool for the job
• Secure your services
• Be a good microservices citizen
• Account for organizational changes
• Automation over everything
@abbyfuller
Let’s talk about ECS
Amazon EC2 Container Service (ECS)
Highly scalable, high performance
container management system.
Eliminates the need to install,
operate, and scale your own
container management
infrastructure.
@abbyfuller
Amazon EC2 Container Service (ECS)
ECS provides a managed platform for:
Container
orchestration
Deep AWS
integration
Cluster
management
How does ECS map to traditional workloads?
Instances: standard EC2 boxes. Once
registered to a Cluster, your Tasks run here
Services: layer that manages and places
Tasks
Tasks: container wrapper and configuration
around processes running on the instance
@abbyfuller
Who is using ECS?
…and many more!
@abbyfuller
Why ECS?
Bottom line: containers and
microservices can require a lot of
orchestration and moving pieces.
ECS removes a lot of this heavy
lifting.
@abbyfuller
Some ECS specific best practices
Some ECS-specific best practices
• Version control your TaskDefinitions, and link back to a specific
commit
• ALB vs ELB
• Cattle, not pets
• Maximize your cluster resources
• Alert, alert, alert
Customize where you need to, and rely on ECS for a sensible baseline.
@abbyfuller
Version control is your friend
• Version control wherever possible
• Container images:
web_app:latest
web_app:dev
web_app:87gbTg4576fdeds6a34c
Better yet: tie those back to a build from a CI/CD system
@abbyfuller
ALB vs ELB
• Highly recommend ALB for ECS:
• Dynamic port mapping
• More efficient use of of resources for microservices- one ALB vs many ELBs
• Route based on anything (path and IP based routing)
• Enhanced Cloudwatch and access logs
@abbyfuller
Cattle not pets
• Cluster servers should be redundant and replaceable
• Don’t plan on anything sticking around
• Limit configuration to the containers themselves, where possible
(some exceptions!)
• If it’s important, or stateful, like logs or data, send it somewhere else
@abbyfuller
Maximize your resources
• Utilize TaskPlacement Policies
• Set sensible resource usage limits
• Set Cluster and Service scaling policies- don’t let resources sit idle!
@abbyfuller
Alert, alert, alert
• Alert where sensible
• Let Services and Cluster scale, but add checks
• Parse logs and alerts to minimize issues and noise
• Take advantage of built-in AWS tools
• aws-logs driver
• Cloudwatch
@abbyfuller
Flexible Orchestration and ECS
Flexibility is about choices
Orchestration platforms should have:
• Sensible defaults
• The ability to extend and customize
Pick one, or a combination of both.
@abbyfuller
Ok, so how can we support flexibility?
A couple of features:
• Task Placement Policies
• Amazon ECS Event Stream for Cloudwatch Events
• Autoscaling at service and cluster level
• Choices! Bring and register your own AMI to ECS
@abbyfuller
First off: you have options
@abbyfuller
Spoiler alert: I like the console
Why the console?
• JSON
• Quicker to test and get started
• Visual feedback
• JSON
@abbyfuller
But the console is not for everyone
If you’re customizing or automating, the CLI might be a better
choice.
Enter clis:
• ecs-cli: open source, takes Docker Compose files
• aws-cli: standard, shared aws-cli with support for ECS
I <3 CLIs
You can use either CLI to
manage container lifecycle
events!
@abbyfuller
Container lifecycle with aws-cli
First stop: creating a cluster
$ aws ecs create-cluster --cluster-name ”meetup"
Should return something like:
{
"cluster": {
"status": "ACTIVE",
"clusterName": ”summit",
"registeredContainerInstancesCount": 0,
"pendingTasksCount": 0,
"runningTasksCount": 0,
"activeServicesCount": 0,
}
}
@abbyfuller
Then, create a task
$ aws ecs register-task-definition --cli-input-json
file://path/meetup.json
You can also use a JSON string:
$ aws ecs register-task-definition --family summit --
container-definitions
"[{"name":”meetup","image":”alpine","cpu":10,
"command":["sleep","360"],"memory":10,"essential
":true}]"
@abbyfuller
Next, use our task to create a service
$ aws ecs create-service --service-name meetup -task-
definition meetup --desired-count 2
You can add more parameters here, such as placement strategy. You
can also register your new service with an ELB/ALB.
@abbyfuller
Meetups are pretty popular. Let’s scale up.
$ aws ecs update-service --service meetup--desired-
count 4
We could use this same command to scale down (which we’ll look at
next), but also to update the task definition. Effectively, deploy a new
version!
@abbyfuller
We don’t want to waste resources though, so
let’s scale back down
$ aws ecs update-service --service meetup --desired-
count 2
In a production environment, this is something we might want to
handle in response to other events: autoscaling!
@abbyfuller
We can also query state
$ aws ecs describe-services --service meetup
This returns A TON of information about our service: most importantly,
it shows us our current deployment, and what events are happening in
our cluster:
"events": [
{
"message": "(service meetup) has
reached a steady state."
@abbyfuller
Bye London!
$ aws ecs delete-cluster --cluster meetup
Important to note that we have to scale our service down to 0, and
remove the service before running this: just in case!
$ aws ecs update-service --service meetup --desired-
count 0
$ aws ecs delete-service --service meetup
@abbyfuller
Some ECS resources
• AWS docs: https://aws.amazon.com/ecs/
• ECS first run wizard:
https://console.aws.amazon.com/ecs/home?region=us-east-1
• Nathan Peck’s ECS repo: https://github.com/nathanpeck/awesome-
ecs
• More talks of mine: https://aws.amazon.com/evangelists/abby-fuller/
• ECS ”Getting Started” workshop: https://www.github.com/abby-
fuller/ecs-demo
@abbyfuller
Thank you!

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

WKS407 Wild Rydes Takes Off – The Dawn of a New Unicorn
WKS407 Wild Rydes Takes Off – The Dawn of a New UnicornWKS407 Wild Rydes Takes Off – The Dawn of a New Unicorn
WKS407 Wild Rydes Takes Off – The Dawn of a New Unicorn
 
HSBC and AWS Day - Big Data and HPC on AWS
HSBC and AWS Day - Big Data and HPC on AWSHSBC and AWS Day - Big Data and HPC on AWS
HSBC and AWS Day - Big Data and HPC on AWS
 
Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
Deep Dive on Object Storage: Amazon S3 and Amazon GlacierDeep Dive on Object Storage: Amazon S3 and Amazon Glacier
Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
 
BDA402 Deep Dive: Log Analytics with Amazon Elasticsearch Service
BDA402 Deep Dive: Log Analytics with Amazon Elasticsearch ServiceBDA402 Deep Dive: Log Analytics with Amazon Elasticsearch Service
BDA402 Deep Dive: Log Analytics with Amazon Elasticsearch Service
 
SEC303 Automating Security in Cloud Workloads with DevSecOps
SEC303 Automating Security in Cloud Workloads with DevSecOpsSEC303 Automating Security in Cloud Workloads with DevSecOps
SEC303 Automating Security in Cloud Workloads with DevSecOps
 
Database Migration – Simple, Cross-Engine and Cross-Platform Migration
Database Migration – Simple, Cross-Engine and Cross-Platform MigrationDatabase Migration – Simple, Cross-Engine and Cross-Platform Migration
Database Migration – Simple, Cross-Engine and Cross-Platform Migration
 
SRV403 Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
SRV403 Deep Dive on Object Storage: Amazon S3 and Amazon GlacierSRV403 Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
SRV403 Deep Dive on Object Storage: Amazon S3 and Amazon Glacier
 
Self-Service Supercomputing
Self-Service SupercomputingSelf-Service Supercomputing
Self-Service Supercomputing
 
(BDT307) Zero Infrastructure, Real-Time Data Collection, and Analytics
(BDT307) Zero Infrastructure, Real-Time Data Collection, and Analytics(BDT307) Zero Infrastructure, Real-Time Data Collection, and Analytics
(BDT307) Zero Infrastructure, Real-Time Data Collection, and Analytics
 
BDA302 Deep Dive on Migrating Big Data Workloads to Amazon EMR
BDA302 Deep Dive on Migrating Big Data Workloads to Amazon EMRBDA302 Deep Dive on Migrating Big Data Workloads to Amazon EMR
BDA302 Deep Dive on Migrating Big Data Workloads to Amazon EMR
 
BDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
BDA403 How Netflix Monitors Applications in Real-time with Amazon KinesisBDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
BDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
 
BDA402 Deep Dive: Log Analytics with Amazon Elasticsearch Service
BDA402 Deep Dive: Log Analytics with Amazon Elasticsearch ServiceBDA402 Deep Dive: Log Analytics with Amazon Elasticsearch Service
BDA402 Deep Dive: Log Analytics with Amazon Elasticsearch Service
 
Selecting the Right AWS Database Solution - AWS 2017 Online Tech Talks
Selecting the Right AWS Database Solution - AWS 2017 Online Tech TalksSelecting the Right AWS Database Solution - AWS 2017 Online Tech Talks
Selecting the Right AWS Database Solution - AWS 2017 Online Tech Talks
 
A Data Culture with Embedded Analytics in Action
A Data Culture with Embedded Analytics in ActionA Data Culture with Embedded Analytics in Action
A Data Culture with Embedded Analytics in Action
 
Database migration simple, cross-engine and cross-platform migrations with ...
Database migration   simple, cross-engine and cross-platform migrations with ...Database migration   simple, cross-engine and cross-platform migrations with ...
Database migration simple, cross-engine and cross-platform migrations with ...
 
Big Data Architectural Patterns
Big Data Architectural PatternsBig Data Architectural Patterns
Big Data Architectural Patterns
 
Deep Dive On Amazon Redshift
Deep Dive On Amazon RedshiftDeep Dive On Amazon Redshift
Deep Dive On Amazon Redshift
 
ENT306 Migrating Large Scale Data Sets to the Cloud
ENT306 Migrating Large Scale Data Sets to the CloudENT306 Migrating Large Scale Data Sets to the Cloud
ENT306 Migrating Large Scale Data Sets to the Cloud
 
Getting Started with Amazon Redshift
Getting Started with Amazon RedshiftGetting Started with Amazon Redshift
Getting Started with Amazon Redshift
 
SRV404 Deep Dive on Amazon DynamoDB
SRV404 Deep Dive on Amazon DynamoDBSRV404 Deep Dive on Amazon DynamoDB
SRV404 Deep Dive on Amazon DynamoDB
 

Semelhante a Building and scaling your containerized microservices on Amazon ECS

T1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on awsT1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on aws
Amazon Web Services
 

Semelhante a Building and scaling your containerized microservices on Amazon ECS (20)

Intro to Amazon ECS
Intro to Amazon ECSIntro to Amazon ECS
Intro to Amazon ECS
 
intro elastic container service amazon aws
intro elastic container service amazon awsintro elastic container service amazon aws
intro elastic container service amazon aws
 
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
 
Introduction to AWS and Docker on ECS
Introduction to AWS and Docker on ECSIntroduction to AWS and Docker on ECS
Introduction to AWS and Docker on ECS
 
Cloud & Native Cloud for Managers
Cloud & Native Cloud for ManagersCloud & Native Cloud for Managers
Cloud & Native Cloud for Managers
 
New AWS Services for Bioinformatics
New AWS Services for BioinformaticsNew AWS Services for Bioinformatics
New AWS Services for Bioinformatics
 
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
 
AWS re:Invent 2016: Running Lean Architectures: How to Optimize for Cost Effi...
AWS re:Invent 2016: Running Lean Architectures: How to Optimize for Cost Effi...AWS re:Invent 2016: Running Lean Architectures: How to Optimize for Cost Effi...
AWS re:Invent 2016: Running Lean Architectures: How to Optimize for Cost Effi...
 
NEW LAUNCH! Introducing AWS Batch: Easy and efficient batch computing
 	  NEW LAUNCH! Introducing AWS Batch: Easy and efficient batch computing 	  NEW LAUNCH! Introducing AWS Batch: Easy and efficient batch computing
NEW LAUNCH! Introducing AWS Batch: Easy and efficient batch computing
 
Tips and Tricks for Running Container Workloads on AWS
Tips and Tricks for Running Container Workloads on AWSTips and Tricks for Running Container Workloads on AWS
Tips and Tricks for Running Container Workloads on AWS
 
從劍宗到氣宗 - 談AWS ECS與Serverless最佳實踐
從劍宗到氣宗  - 談AWS ECS與Serverless最佳實踐從劍宗到氣宗  - 談AWS ECS與Serverless最佳實踐
從劍宗到氣宗 - 談AWS ECS與Serverless最佳實踐
 
ENT302 Deep Dive on AWS Management Tools
ENT302 Deep Dive on AWS Management Tools ENT302 Deep Dive on AWS Management Tools
ENT302 Deep Dive on AWS Management Tools
 
Amazon Batch: 實現簡單且有效率的批次運算
Amazon Batch: 實現簡單且有效率的批次運算Amazon Batch: 實現簡單且有效率的批次運算
Amazon Batch: 實現簡單且有效率的批次運算
 
AWS Lambda at JUST EAT
AWS Lambda at JUST EATAWS Lambda at JUST EAT
AWS Lambda at JUST EAT
 
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
 
T1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on awsT1 – Architecting highly available applications on aws
T1 – Architecting highly available applications on aws
 
Introduction to AWS Batch
Introduction to AWS BatchIntroduction to AWS Batch
Introduction to AWS Batch
 
Managing Your Cloud Assets
Managing Your Cloud AssetsManaging Your Cloud Assets
Managing Your Cloud Assets
 
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
 
UCT AWS_IOT
UCT AWS_IOTUCT AWS_IOT
UCT AWS_IOT
 

Mais de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Mais de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Building and scaling your containerized microservices on Amazon ECS

  • 1. Building and scaling your containerized microservices on Amazon ECS Abby Fuller, AWS @abbyfuller
  • 2. Agenda • Quick microservices overview • Let’s talk about ECS • Some ECS best practices • Flexible orchestration and ECS • Container lifecycle with aws-cli • Questions?
  • 4. What are microservices? “Service-oriented architecture composed of loosely coupled elements that have bounded contexts” Adrian Cockcroft (VP of Cloud Architecture @ AWS, former Cloud Architect at Netflix)
  • 5. A few microservices best practices • Rely on the public API • Use the right tool for the job • Secure your services • Be a good microservices citizen • Account for organizational changes • Automation over everything @abbyfuller
  • 7. Amazon EC2 Container Service (ECS) Highly scalable, high performance container management system. Eliminates the need to install, operate, and scale your own container management infrastructure. @abbyfuller
  • 8. Amazon EC2 Container Service (ECS) ECS provides a managed platform for: Container orchestration Deep AWS integration Cluster management
  • 9. How does ECS map to traditional workloads? Instances: standard EC2 boxes. Once registered to a Cluster, your Tasks run here Services: layer that manages and places Tasks Tasks: container wrapper and configuration around processes running on the instance @abbyfuller
  • 10. Who is using ECS? …and many more! @abbyfuller
  • 11. Why ECS? Bottom line: containers and microservices can require a lot of orchestration and moving pieces. ECS removes a lot of this heavy lifting. @abbyfuller
  • 12. Some ECS specific best practices
  • 13. Some ECS-specific best practices • Version control your TaskDefinitions, and link back to a specific commit • ALB vs ELB • Cattle, not pets • Maximize your cluster resources • Alert, alert, alert Customize where you need to, and rely on ECS for a sensible baseline. @abbyfuller
  • 14. Version control is your friend • Version control wherever possible • Container images: web_app:latest web_app:dev web_app:87gbTg4576fdeds6a34c Better yet: tie those back to a build from a CI/CD system @abbyfuller
  • 15. ALB vs ELB • Highly recommend ALB for ECS: • Dynamic port mapping • More efficient use of of resources for microservices- one ALB vs many ELBs • Route based on anything (path and IP based routing) • Enhanced Cloudwatch and access logs @abbyfuller
  • 16. Cattle not pets • Cluster servers should be redundant and replaceable • Don’t plan on anything sticking around • Limit configuration to the containers themselves, where possible (some exceptions!) • If it’s important, or stateful, like logs or data, send it somewhere else @abbyfuller
  • 17. Maximize your resources • Utilize TaskPlacement Policies • Set sensible resource usage limits • Set Cluster and Service scaling policies- don’t let resources sit idle! @abbyfuller
  • 18. Alert, alert, alert • Alert where sensible • Let Services and Cluster scale, but add checks • Parse logs and alerts to minimize issues and noise • Take advantage of built-in AWS tools • aws-logs driver • Cloudwatch @abbyfuller
  • 20. Flexibility is about choices Orchestration platforms should have: • Sensible defaults • The ability to extend and customize Pick one, or a combination of both. @abbyfuller
  • 21. Ok, so how can we support flexibility? A couple of features: • Task Placement Policies • Amazon ECS Event Stream for Cloudwatch Events • Autoscaling at service and cluster level • Choices! Bring and register your own AMI to ECS @abbyfuller
  • 22. First off: you have options @abbyfuller
  • 23. Spoiler alert: I like the console Why the console? • JSON • Quicker to test and get started • Visual feedback • JSON @abbyfuller
  • 24. But the console is not for everyone If you’re customizing or automating, the CLI might be a better choice. Enter clis: • ecs-cli: open source, takes Docker Compose files • aws-cli: standard, shared aws-cli with support for ECS I <3 CLIs You can use either CLI to manage container lifecycle events! @abbyfuller
  • 26. First stop: creating a cluster $ aws ecs create-cluster --cluster-name ”meetup" Should return something like: { "cluster": { "status": "ACTIVE", "clusterName": ”summit", "registeredContainerInstancesCount": 0, "pendingTasksCount": 0, "runningTasksCount": 0, "activeServicesCount": 0, } } @abbyfuller
  • 27. Then, create a task $ aws ecs register-task-definition --cli-input-json file://path/meetup.json You can also use a JSON string: $ aws ecs register-task-definition --family summit -- container-definitions "[{"name":”meetup","image":”alpine","cpu":10, "command":["sleep","360"],"memory":10,"essential ":true}]" @abbyfuller
  • 28. Next, use our task to create a service $ aws ecs create-service --service-name meetup -task- definition meetup --desired-count 2 You can add more parameters here, such as placement strategy. You can also register your new service with an ELB/ALB. @abbyfuller
  • 29. Meetups are pretty popular. Let’s scale up. $ aws ecs update-service --service meetup--desired- count 4 We could use this same command to scale down (which we’ll look at next), but also to update the task definition. Effectively, deploy a new version! @abbyfuller
  • 30. We don’t want to waste resources though, so let’s scale back down $ aws ecs update-service --service meetup --desired- count 2 In a production environment, this is something we might want to handle in response to other events: autoscaling! @abbyfuller
  • 31. We can also query state $ aws ecs describe-services --service meetup This returns A TON of information about our service: most importantly, it shows us our current deployment, and what events are happening in our cluster: "events": [ { "message": "(service meetup) has reached a steady state." @abbyfuller
  • 32. Bye London! $ aws ecs delete-cluster --cluster meetup Important to note that we have to scale our service down to 0, and remove the service before running this: just in case! $ aws ecs update-service --service meetup --desired- count 0 $ aws ecs delete-service --service meetup @abbyfuller
  • 33. Some ECS resources • AWS docs: https://aws.amazon.com/ecs/ • ECS first run wizard: https://console.aws.amazon.com/ecs/home?region=us-east-1 • Nathan Peck’s ECS repo: https://github.com/nathanpeck/awesome- ecs • More talks of mine: https://aws.amazon.com/evangelists/abby-fuller/ • ECS ”Getting Started” workshop: https://www.github.com/abby- fuller/ecs-demo @abbyfuller