Design, Deployment und Betreiben von Microservices

... using Amazon EC2 Container. Service to power our new programming assignments infrastructure for next-generation. On-Demand course platform.” Page 27 ...
4MB Größe 0 Downloads 274 Ansichten
Design, Deployment und Betreiben von Microservices mit Docker und dem EC2 Container Sevice

Oliver Arafat, Enterprise Evangelist, AWS [email protected] @OliverArafat Microservices Webday

Agenda • • • •

What are Containers? EC2 Container Service Common Patterns Demo

What are Containers?

“Shipping code to the server is hard!” Solomon Hykes, CTO & Founder of Docker

Anwendungskomplexität Java, Go, Python, JavaScript, C#, C, C++, Ruby, Perl, PHP

.NET, LAMP, Java EE, Node, Rails, Erlang

Web Front End, API Endpoint, Queues, Analytics DB

MySQL, PostgreSQL, CouchDB, MongoDB, Cassandra

Java, Go, Python, JavaScript, C#, C, C++, Ruby, Perl, PHP

Web Front End, API Endpoint, Queues, Analytics DB

.NET, LAMP, Java EE, Node, Rails, Erlang

MySQL, PostgreSQL, CouchDB, MongoDB, Cassandra

On Premise

Cloud

Dev

Test

Staging

Prod

Java, Go, Python, JavaScript, C#, C, C++, Ruby, Perl, PHP

Web Front End, API Endpoint, Queues, Analytics DB

.NET, LAMP, Java EE, Node, Rails, Erlang

On Premise

Cloud

Dev

Test

Staging

Prod

MySQL, PostgreSQL, CouchDB, MongoDB, Cassandra

How is this different from VMs? Virtual Machines

Containers

Container advantages

Portable

Container advantages

Flexible

Container advantages

Fast

Container advantages

Efficient

A container pipeline IT Operations

Utilities

Patches

Base image

A container pipeline IT Operations

Ruby Utilities

Patches

Redis Base image Logger

A container pipeline IT Operations

Developer

Ruby Utilities

Patches

Redis Base image Logger

App

A container pipeline IT Operations

Developer

Ruby Utilities

Patches

Redis Base image Logger

App

App1

App2

Bins/Libs

Bins/Lib s

Guest OS Server

Amazon EC2 Container Service

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

Scheduling aka 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 (IAM) • AWS CloudTrail • Amazon CloudWatch

Extensible

• Comprehensive APIs • Open source agent • Custom schedulers

Common Patterns

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.”

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.”

Amazon ECS Terminology

Key Components: Container Instances

Amazon EC2 instances Docker daemon Amazon ECS agent

Key Components: Clusters Regional Resource pool Grouping of container instances Start empty, dynamically scalable

Key Components: Task Definitions

Volume definitions

Container definitions

Key Components: Task Definitions

Shared data volume

PHP app

Time of day app

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 }

Key components: task definitions { "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-

[ {

Expose port 80 in container to port 80 on host

Create and mount volumes

vol" } ], "entryPoint": [ "/usr/sbin/apache2", "-D", "FOREGROUND" ], "essential": true },

10 CPU Units (1024 is full CPU), 500 megabytes of memory

"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

Key Components: Task Definitions From Docker Hub Mount volume from other container

Command to exec

{ "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: Tasks

Shared data volume Schedule PHP app

Time of day app Container Instance

Key Components: Tasks

Unit of work Grouping of related containers Run on container instances

Key Components: Run a task

Good for short-lived containers, e.g. batch jobs

Key components: Create a service

Good for longrunning applications and services

Key components: Create a service • Load balance traffic across containers • Automatically recover unhealthy containers

Elastic Load Balancing

Key components: Update a service • (Automated) Scale up • (Automated) Scale down

Elastic Load Balancing

Key components: Update a service • Deploy a new version • Drain connections

Elastic Load Balancing

Demo

AWS Free Tier

aws.amazon.com/free

Thank you! Questions? Oliver Arafat, Enterprise Evangelist AWS [email protected] @OliverArafat Microservices Webday