43
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved Introducing Amazon ECS CLI Chris Barclay Amazon Web Services

AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

Embed Size (px)

Citation preview

Page 1: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

©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

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

Containers

Page 4: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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

EC2 Container Service

Page 6: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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

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

Scalable

Page 9: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

Flexible Container Placement

Applications

Batch jobs

Multiple schedulers

Page 10: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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

Extensible

Comprehensive APIs

Open source agent

Custom schedulers

Page 12: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

Services

Page 13: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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

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

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

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

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

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

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

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

Walk through

Page 22: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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

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

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

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

Typical user workflow

Describe Service

Page 27: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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

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

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

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

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

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

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

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

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

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

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

©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

Docker Compose

Page 40: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

Demo: ECS Console

Page 41: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

Demo: ECS CLI

Page 42: AWS November Webinar Series - From Local Development to Production Using the Amazon ECS CLI

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