amazon ec2 container service

38
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved Amazon EC2 Container Service: Manage Docker-Enabled Apps in EC2 Jafar Shameem

Upload: amazon-web-services

Post on 12-Aug-2015

419 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Amazon EC2 Container Service

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

Amazon EC2 Container Service:

Manage Docker-Enabled Apps in EC2

Jafar Shameem

Page 2: Amazon EC2 Container Service

Agenda

• Containers

• EC2 Container Service

Page 3: Amazon EC2 Container Service

Containers

Page 4: Amazon EC2 Container Service

What are containers?

• OS virtualization

• Process isolation

• Images

• Automation Server

Guest OS

Bins/Libs Bins/Libs

App2App1

Page 5: Amazon EC2 Container Service

Container advantages

PortableSame Immutable Images. Run anywhere.

FlexibleCreate Modular Environments. Decompose Apps

FastSpeeds up build and release cycle

EfficientOptimize resource utilization

Server

Guest OS

Bins/Libs Bins/Libs

App2App1

Page 6: Amazon EC2 Container Service

A container pipeline

Base

image

Patches

IT Operations

Utilities

Page 7: Amazon EC2 Container Service

A container pipeline

Base

image

Patches

IT Operations

Ruby

Redis

Logger

Utilities

Page 8: Amazon EC2 Container Service

A container pipeline

Base

image

Patches

IT Operations Developer

Ruby

Redis

Logger

Utilities

App

Page 9: Amazon EC2 Container Service

A container pipeline

Base

image

Patches

IT Operations Developer

Ruby

Redis

Logger

Utilities

App

Page 10: Amazon EC2 Container Service

Server

Guest OS

Bins/Libs Bins/Libs

App2App1

$ docker run myimage

Page 11: Amazon EC2 Container Service
Page 12: Amazon EC2 Container Service

EC2 Container Service

Page 13: Amazon EC2 Container Service

Easily Manage Clusters for Any Scale

• Nothing to run

• Complete state

• Control and monitoring

• Scale

ECS List* and Describe* API actions

Page 14: Amazon EC2 Container Service

Flexible Container Placement

• Applications

• Batch jobs

• Multiple schedulers

Page 15: Amazon EC2 Container Service

Designed for use with other AWS services

• Virtual Private Cloud

• Elastic Load Balancing

• Elastic Block Store

• IAM

• CloudTrail

Page 16: Amazon EC2 Container Service

Extensible

• Comprehensive APIs

• Open source agent

• Custom schedulers

Page 17: Amazon EC2 Container Service

Common Patterns

Page 18: Amazon EC2 Container Service

Pattern 1: Services and applications

• Simple to model

• Micro services

• Blue / green

deployments

Phong Nguyen, Founder at Gilt

Groupe, said, "As we Dockerize

all our services, it is very

important for us to have a

platform that can help us speed

up deployments, automate our

services, and gain greater

efficiencies. The new service

scheduler and ELB integration

make Amazon ECS an excellent

platform for our services.”

Page 19: Amazon EC2 Container Service

Pattern 2: Batch jobs

• Share resource pools

• Ideal for bursty jobs

• Spot instances

“We required a solution on which

we could securely and efficiently

deploy Docker containers to

encapsulate learner

programming assignment

submissions,” said Brennan

Saeta, Architect at Coursera. “We

are using Amazon EC2 Container

Service to power our new

programming assignments

infrastructure for next-generation

On-Demand course platform.”

Page 20: Amazon EC2 Container Service

EC2 Container Service Terminology

Page 21: Amazon EC2 Container Service

• Regional

• Resource pool

• Grouping of Container Instances

• Start empty, dynamically scalable

Key Components: Clusters

Page 22: Amazon EC2 Container Service

• Amazon EC2 instances

• Docker daemon

• Amazon ECS agent

Key Components: Container Instances

Page 23: Amazon EC2 Container Service

Key Components: Task Definitions

Volume definitions

Container definitions

Page 24: Amazon EC2 Container Service

Key Components: Task Definitions{

"environment": [],

"name": "simple-demo",

"image": "my-demo",

"cpu": 10,

"memory": 500,

"portMappings": [

{

"containerPort": 80,

"hostPort": 80

}

],

"mountPoints": [

{

"sourceVolume": "my-vol",

"containerPath": "/var/www/my-

vol"

}

],

"entryPoint": [

"/usr/sbin/apache2",

"-D",

"FOREGROUND"

],

"essential": true

},

{

"name": "busybox",

"image": "busybox",

"cpu": 10,

"memory": 500,

"volumesFrom": [

{

"sourceContainer": "simple-demo"

}

],

"entryPoint": [

"sh",

"-c"

],

"command": [

"/bin/sh -c \"while true; do

/bin/date > /var/www/my-vol/date; sleep 1; done\""

],

"essential": false

}

Page 25: Amazon EC2 Container Service

{

"environment": [],

"name": "simple-demo",

"image": “amazon/amazon-ecs-sample",

"cpu": 10,

"memory": 500,

"portMappings": [

{

"containerPort": 80,

"hostPort": 80

}

],

"mountPoints": [

{

"sourceVolume": "my-vol",

"containerPath": "/var/www/my-

vol"

}

],

"entryPoint": [

"/usr/sbin/apache2",

"-D",

"FOREGROUND"

],

"essential": true

},

Key Components: Task Definitions[

{

"image": "mysql",

"name": "db",

"cpu": 10,

"memory": 500,

"essential": true,

"entryPoint": [

"/entrypoint.sh"

],

"environment": [

{

"name": "MYSQL_ROOT_PASSWORD",

"value": "pass"

}

],

"portMappings": []

}

]

Essential to our Task

Create and mount volumes

Expose port 80 in container

to port 80 on host

10 CPU Units (1024 is full CPU),

500 Megabytes of Memory

Page 26: Amazon EC2 Container Service

{

"name": "busybox",

"image": "busybox",

"cpu": 10,

"memory": 500,

"volumesFrom": [

{

"sourceContainer": "simple-demo"

}

],

"entryPoint": [

"sh",

"-c"

],

"command": [

"/bin/sh -c \"while true; do

/bin/date > /var/www/my-vol/date; sleep 1; done\""

],

"essential": false

}

Key Components: Task Definitions[

{

"image": "tutum/wordpress-stackable",

"name": "wordpress",

"cpu": 10,

"memory": 500,

"essential": true,

"links": [

"db"

],

"entryPoint": [

"/bin/sh",

"-c"

],

"environment": [

],

"portMappings": [

{

"containerPort": 80,

"hostPort": 80

}

]

},

]

From Docker Hub

Mount volume from other container

Command to exec

Page 27: Amazon EC2 Container Service

• Unit of work

• Grouping of related Containers

• Run on Container Instances

Key Components: Tasks

Page 28: Amazon EC2 Container Service

Key Components: Tasks

Container

Instance

Schedule

Shared data volume

PHP AppTime of day

App

Page 29: Amazon EC2 Container Service

Key Components: Run a task

Good for short-lived

containers, e.g.

batch jobs

Page 30: Amazon EC2 Container Service

Key Components: Create a Service

Good for long-

running applications

and services

Page 31: Amazon EC2 Container Service
Page 32: Amazon EC2 Container Service

Key Components: Create Service

• Load Balance traffic across containers

• Automatically recover unhealthy containers

• Discover services

Elastic Load Balancing

Page 33: Amazon EC2 Container Service

Key Components: Update Service

• Scale up

• Scale down

Elastic Load Balancing

Page 34: Amazon EC2 Container Service

Key Components: Update Service

• Deploy new version

• Drain connections

Elastic Load Balancing

Page 35: Amazon EC2 Container Service

Key Components: Update Service

• Deploy new version

• Drain connections

Elastic Load Balancing

Page 36: Amazon EC2 Container Service

Key Components: Update Service

• Deploy new version

• Drain connections

Elastic Load Balancing

Page 37: Amazon EC2 Container Service

More resources

• Service Discovery via Consul with ECS:– https://aws.amazon.com/blogs/compute/service-discovery-via-

consul-with-amazon-ecs/

• Running an Amazon ECS Task on every instance:– https://aws.amazon.com/blogs/compute/running-an-amazon-ecs-

task-on-every-instance/

• Set up a build pipeline with Jenkins and ECS:– https://blogs.aws.amazon.com/application-

management/post/Tx32RHFZHXY6ME1/Set-up-a-build-pipeline-with-Jenkins-and-Amazon-ECS

Page 38: Amazon EC2 Container Service

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

Thank You