aws november webinar series - from local development to production using the amazon ecs cli

Post on 12-Apr-2017

1.533 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved

Introducing Amazon ECS CLIChris Barclay

Amazon Web Services

Agenda

Containers

EC2 Container Service

Development process

Q&A

Containers

Container Benefits

Environment consistency

Developer productivity

Version control Operational efficiency

EC2 Container Service

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

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

Scalable

Flexible Container Placement

Applications

Batch jobs

Multiple schedulers

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

Extensible

Comprehensive APIs

Open source agent

Custom schedulers

Services

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

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

A container pipelineIT Operations

Base Image

Ubuntu 14.04PatchesUtilities

A container pipelineIT Operations

Base Image

Ruby Redis Logger

A container pipelineIT Operations Developer

Base Image

App

Code

Ruby Redis Logger

A container pipelineIT Operations Developer

Base Image

App

Ruby Redis Logger

A container pipelineIT Operations Developer

Base Image

Patches

App

Ruby Redis Logger

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

Walk through

Typical user workflow

I want to run a service

Typical user workflow

Run Instances AmazonEC2

Use custom AMI with Docker support and ECS Agent. Instances will register with default cluster.

Typical user workflow

Create Task Definition

Declare resource requirements for containers

Shared Data Volume

PHP App Time of day App

Typical user workflow

Create Service

Declare resource requirements for service

Shared Data Volume

PHP App Time of day App

Elastic Load

Balancing

X 5

Typical user workflow

Describe Service

Typical user workflow

Scale Service

Drain Connections

Shared Data Volume

PHP App Time of day App

Elastic Load

Balancing

X 2

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

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

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

Docker Compose

Model multi-container services

Run on desktop and AWS

Store in source control

web:  image: amazon/amazon-ecs-sample  ports:   - "80:80"

Run Compose Locally

Run Compose on the local dev environment

$ docker-compose upCreating compose_web_1...Attaching to compose_web_1

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

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

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

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

Considerations

Compose support

ECS services and ELBs

Service discovery

©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved

Q&A

Docker Compose

Demo: ECS Console

Demo: 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

top related