Design, Deployment und Betreiben von Microservices mit Docker ...

44
Design, Deployment und Betreiben von Microservices mit Docker und dem EC2 Container Sevice Oliver Arafat, Enterprise Evangelist, AWS [email protected] @OliverArafat Microservices Webday

Transcript of Design, Deployment und Betreiben von Microservices mit Docker ...

Page 1: Design, Deployment und Betreiben von Microservices mit Docker ...

Design, Deployment und Betreiben von

Microservices mit Docker und dem EC2

Container Sevice

Oliver Arafat, Enterprise Evangelist, AWS

[email protected]

@OliverArafat

Microservices Webday

Page 2: Design, Deployment und Betreiben von Microservices mit Docker ...

Agenda

• What are Containers?

• EC2 Container Service

• Common Patterns

• Demo

Page 3: Design, Deployment und Betreiben von Microservices mit Docker ...

What are Containers?

Page 4: Design, Deployment und Betreiben von Microservices mit Docker ...

“Shipping code to the server is

hard!”

Solomon Hykes, CTO & Founder of Docker

Page 5: Design, Deployment und Betreiben von Microservices mit Docker ...

Anwendungskomplexität

Java, Go, Python,

JavaScript, C#, C, C++, Ruby, Perl,

PHP

.NET, LAMP, Java EE,

Node, Rails, Erlang

MySQL, PostgreSQL,

CouchDB, MongoDB, Cassandra

Web Front End, API Endpoint, Queues,

Analytics DB

Page 6: Design, Deployment und Betreiben von Microservices mit Docker ...

Java, Go, Python,

JavaScript, C#, C, C++, Ruby, Perl,

PHP

.NET, LAMP, Java EE,

Node, Rails, Erlang

MySQL, PostgreSQL,

CouchDB, MongoDB, Cassandra

Web Front End, API Endpoint, Queues,

Analytics DB

On

PremiseCloud

Dev Test

ProdStaging

Page 7: Design, Deployment und Betreiben von Microservices mit Docker ...

Java, Go, Python,

JavaScript, C#, C, C++, Ruby, Perl,

PHP

.NET, LAMP, Java EE,

Node, Rails, Erlang

MySQL, PostgreSQL,

CouchDB, MongoDB, Cassandra

Web Front End, API Endpoint, Queues,

Analytics DB

On

PremiseCloud

Dev Test

ProdStaging

Page 8: Design, Deployment und Betreiben von Microservices mit Docker ...

How is this different from VMs?

Virtual Machines Containers

Page 9: Design, Deployment und Betreiben von Microservices mit Docker ...

Container advantages

Portable

Page 10: Design, Deployment und Betreiben von Microservices mit Docker ...

Container advantages

Flexible

Page 11: Design, Deployment und Betreiben von Microservices mit Docker ...

Container advantages

Fast

Page 12: Design, Deployment und Betreiben von Microservices mit Docker ...

Container advantages

Efficient

Page 13: Design, Deployment und Betreiben von Microservices mit Docker ...

A container pipeline

Base

image

Patches

IT Operations

Utilities

Page 14: Design, Deployment und Betreiben von Microservices mit Docker ...

A container pipeline

Base

image

Patches

IT Operations

Ruby

Redis

Logger

Utilities

Page 15: Design, Deployment und Betreiben von Microservices mit Docker ...

A container pipeline

Base

image

Patches

IT Operations Developer

Ruby

Redis

Logger

Utilities

App

Page 16: Design, Deployment und Betreiben von Microservices mit Docker ...

A container pipeline

Base

image

Patches

IT Operations Developer

Ruby

Redis

Logger

Utilities

App

Page 17: Design, Deployment und Betreiben von Microservices mit Docker ...

Server

Bins/Libs

Guest OS

Bins/Lib

s

App2App1

Page 18: Design, Deployment und Betreiben von Microservices mit Docker ...
Page 19: Design, Deployment und Betreiben von Microservices mit Docker ...

Amazon EC2 Container Service

Page 20: Design, Deployment und Betreiben von Microservices mit Docker ...

Easily manage clusters for any scale

• Eliminates cluster management software

• Manages cluster state

• Control and monitoring

• Scale from one to tens of thousands of

containers

Page 21: Design, Deployment und Betreiben von Microservices mit Docker ...

Scheduling aka Flexible Container Placement

• Applications

• Batch jobs

• Multiple schedulers

Page 22: Design, Deployment und Betreiben von Microservices mit Docker ...

Designed for use with other AWS services

• Elastic Load Balancing

• Amazon Elastic Block Store

• Amazon Virtual Private Cloud

• AWS Identity and Access

Management (IAM)

• AWS CloudTrail

• Amazon CloudWatch

Page 23: Design, Deployment und Betreiben von Microservices mit Docker ...

Extensible

• Comprehensive APIs

• Open source agent

• Custom schedulers

Page 24: Design, Deployment und Betreiben von Microservices mit Docker ...

Common Patterns

Page 25: Design, Deployment und Betreiben von Microservices mit Docker ...

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 26: Design, Deployment und Betreiben von Microservices mit Docker ...

Pattern 2: Batch jobs

• Share resource pools

• Ideal for short-lived

and 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 27: Design, Deployment und Betreiben von Microservices mit Docker ...

Amazon ECS Terminology

Page 28: Design, Deployment und Betreiben von Microservices mit Docker ...

Amazon EC2 instances

Docker daemon

Amazon ECS agent

Key Components: Container Instances

Page 29: Design, Deployment und Betreiben von Microservices mit Docker ...

Regional

Resource pool

Grouping of container instances

Start empty, dynamically scalable

Key Components: Clusters

Page 30: Design, Deployment und Betreiben von Microservices mit Docker ...

Key Components: Task Definitions

Volume definitions

Container definitions

Page 31: Design, Deployment und Betreiben von Microservices mit Docker ...

Key Components: Task Definitions

Shared data volume

PHP appTime of day

app

Page 32: Design, Deployment und Betreiben von Microservices mit Docker ...

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 33: Design, Deployment und Betreiben von Microservices mit Docker ...

{

"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 34: Design, Deployment und Betreiben von Microservices mit Docker ...

{

"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

From Docker Hub

Mount volume from other container

Command to exec

Page 35: Design, Deployment und Betreiben von Microservices mit Docker ...

Key Components: Tasks

Container

Instance

Schedule

Shared data volume

PHP appTime of day

app

Page 36: Design, Deployment und Betreiben von Microservices mit Docker ...

Unit of work

Grouping of related containers

Run on container instances

Key Components: Tasks

Page 37: Design, Deployment und Betreiben von Microservices mit Docker ...

Key Components: Run a task

Good for short-lived

containers, e.g.

batch jobs

Page 38: Design, Deployment und Betreiben von Microservices mit Docker ...

Key components: Create a service

Good for long-

running applications

and services

Page 39: Design, Deployment und Betreiben von Microservices mit Docker ...

Key components: Create a service

• Load balance traffic across containers

• Automatically recover unhealthy containers

Elastic Load Balancing

Page 40: Design, Deployment und Betreiben von Microservices mit Docker ...

Key components: Update a service

• (Automated) Scale up

• (Automated) Scale down

Elastic Load Balancing

Page 41: Design, Deployment und Betreiben von Microservices mit Docker ...

Key components: Update a service

• Deploy a new version

• Drain connections

Elastic Load Balancing

Page 42: Design, Deployment und Betreiben von Microservices mit Docker ...

Demo

Page 43: Design, Deployment und Betreiben von Microservices mit Docker ...

AWS Free Tier

aws.amazon.com/free

Page 44: Design, Deployment und Betreiben von Microservices mit Docker ...

Thank you!

Questions?

Oliver Arafat, Enterprise Evangelist AWS

[email protected]

@OliverArafat

Microservices Webday