aws november webinar series - from local development to production using the amazon ecs cli
TRANSCRIPT
![Page 1: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/1.jpg)
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved
Introducing Amazon ECS CLIChris Barclay
Amazon Web Services
![Page 2: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/2.jpg)
Agenda
Containers
EC2 Container Service
Development process
Q&A
![Page 3: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/3.jpg)
Containers
![Page 4: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/4.jpg)
Container Benefits
Environment consistency
Developer productivity
Version control Operational efficiency
![Page 5: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/5.jpg)
EC2 Container Service
![Page 6: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/6.jpg)
Architecture
DockerTask
Container Instance
Amazon ECS
Container
ECS Agent
ELB
Internet
ELB
User / Scheduler
API
Cluster Management Engine
TaskContainer
DockerTask
Container Instance
Container
ECS Agent
TaskContainer
DockerTask
Container Instance
Container
ECS Agent
TaskContainer
AZ 1 AZ 2
Key/Value Store
Agent Communication Service
![Page 7: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/7.jpg)
Cluster Management Made Easy
No cluster software to install and manage
Manages cluster state
Manages containers
Control and monitoring
Scale from one to tens of thousands of containers
![Page 8: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/8.jpg)
Scalable
![Page 9: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/9.jpg)
Flexible Container Placement
Applications
Batch jobs
Multiple schedulers
![Page 10: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/10.jpg)
Designed for use with other AWS services
Elastic Load Balancing
Amazon Elastic Block Store
Amazon Virtual Private Cloud
AWS Identity and Access Management
AWS CloudTrail
![Page 11: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/11.jpg)
Extensible
Comprehensive APIs
Open source agent
Custom schedulers
![Page 12: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/12.jpg)
Services
![Page 13: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/13.jpg)
Services evolve to microservices
MVC Application
Order UI User UI Shipping UI
OrderService
UserService
ShippingService
DataAccess
Host 1
Service A
Service B
Host 2
Service B
Service D
Host 3
Service A
Service C
Host 4
Service B
Service C
![Page 14: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/14.jpg)
Containers are natural for services
Simple to model
Any app, any language
Image is the version
Test & deploy same artifact
Stateless servers decrease change risk
![Page 15: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/15.jpg)
A container pipelineIT Operations
Base Image
Ubuntu 14.04PatchesUtilities
![Page 16: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/16.jpg)
A container pipelineIT Operations
Base Image
Ruby Redis Logger
![Page 17: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/17.jpg)
A container pipelineIT Operations Developer
Base Image
App
Code
Ruby Redis Logger
![Page 18: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/18.jpg)
A container pipelineIT Operations Developer
Base Image
App
Ruby Redis Logger
![Page 19: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/19.jpg)
A container pipelineIT Operations Developer
Base Image
Patches
App
Ruby Redis Logger
![Page 20: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/20.jpg)
Task definitions
Processes that run together on the same instance
Scale in tandem
May share common resources such as files, or links
Often exposed through one endpoint
![Page 21: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/21.jpg)
Walk through
![Page 22: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/22.jpg)
Typical user workflow
I want to run a service
![Page 23: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/23.jpg)
Typical user workflow
Run Instances AmazonEC2
Use custom AMI with Docker support and ECS Agent. Instances will register with default cluster.
![Page 24: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/24.jpg)
Typical user workflow
Create Task Definition
Declare resource requirements for containers
Shared Data Volume
PHP App Time of day App
![Page 25: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/25.jpg)
Typical user workflow
Create Service
Declare resource requirements for service
Shared Data Volume
PHP App Time of day App
Elastic Load
Balancing
X 5
![Page 26: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/26.jpg)
Typical user workflow
Describe Service
![Page 27: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/27.jpg)
Typical user workflow
Scale Service
Drain Connections
Shared Data Volume
PHP App Time of day App
Elastic Load
Balancing
X 2
![Page 28: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/28.jpg)
Typical user workflow
Deploy new version
Rolling deployment, health checks, drain connections
Shared Data Volume
PHP App Time of day App
Elastic Load
Balancing
X 2
![Page 29: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/29.jpg)
ECS CLI
High-level commands to simplify creating, updating, and monitoring clusters and tasks
Supports Docker Compose, a popular open-source tool for defining and running multi-container applications
Binaries available for Mac OSX and Linux
Open source, download, comment https://github.com/aws/amazon-ecs-cli
![Page 30: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/30.jpg)
Create an ECS cluster
Creates all the resources required by your cluster in one command
$ ecs-cli up --keypair id_rsa --capability-iam --size 2 --instance-type t2.medium INFO[0000] Created cluster cluster=ecs-cli-demo INFO[0000] Waiting for your cluster resources to be created INFO[0001] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS
![Page 31: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/31.jpg)
Docker Compose
Model multi-container services
Run on desktop and AWS
Store in source control
web: image: amazon/amazon-ecs-sample ports: - "80:80"
![Page 32: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/32.jpg)
Run Compose Locally
Run Compose on the local dev environment
$ docker-compose upCreating compose_web_1...Attaching to compose_web_1
![Page 33: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/33.jpg)
Deploy the Compose File to an ECS Cluster
Can run stand-alone tasks or create an ECS service
$ ecs-cli compose service up INFO[0000] Using ECS task definition TaskDefinition=ecscompose-cli-webinar:1INFO[0000] Created an ECS Service serviceName=ecscompose-service-cli-webinar taskDefinition=ecscompose-cli-webinar:1INFO[0000] Updated ECS service successfully desiredCount=1 serviceName=ecscompose-service-cli-webinarINFO[0000] Describe ECS Service status desiredCount=1 runningCount=0 serviceName=ecscompose-service-cli-webinar
![Page 34: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/34.jpg)
View the Running Containers
View what you created
$ ecs-cli service ps Name State Ports TaskDefinition46163c8a-fd75-481d-a670-1bda9f433493/web RUNNING 52.91.66.37:80->80/tcp ecscompose-cli-webinar:1
![Page 35: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/35.jpg)
Scale your service
Add more tasks to scale the service
$ ecs-cli compose service scale 2INFO[0000] Updated ECS service successfully desiredCount=2 serviceName=ecscompose-service-cli-webinarINFO[0000] Describe ECS Service status desiredCount=2 runningCount=1 serviceName=ecscompose-service-cli-webinar
![Page 36: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/36.jpg)
Update your service
Change docker-compose.yml to include an nginx proxy and redeploy
$ ecs-cli compose service upINFO[0000] Using ECS task definition TaskDefinition=ecscompose-cli-webinar:2INFO[0000] Updated the ECS service with a new task definition. Old containers will be stopped automatically, and replaced with new ones desiredCount=2 serviceName=ecscompose-service-cli-webinar taskDefinition=ecscompose-cli-webinar:2INFO[0000] ECS Service has reached a stable state desiredCount=2 runningCount=2 serviceName=ecscompose-service-cli-webinar
![Page 37: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/37.jpg)
Considerations
Compose support
ECS services and ELBs
Service discovery
![Page 38: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/38.jpg)
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved
Q&A
![Page 39: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/39.jpg)
Docker Compose
![Page 40: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/40.jpg)
Demo: ECS Console
![Page 41: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/41.jpg)
Demo: ECS CLI
![Page 42: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/42.jpg)
Create Docker Compose file
Run & share multi-container servicesWork on desktop and AWS1) git clone2) docker-compose up3) open app in browser
Thanks to Jerome Petazzoni (@jpetazzo) from Docker https://github.com/jpetazzo/trainingwheels
www: build: www ports: - 80:5000 links: - redis mem_limit: 200000000
redis: image: redis mem_limit: 50000000
![Page 43: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI](https://reader035.vdocuments.us/reader035/viewer/2022070523/58ed8c621a28ab0d278b45e5/html5/thumbnails/43.jpg)