48
Sascha Möllering | zanox AG Docker in the Cloud

Docker in the Cloud

Embed Size (px)

Citation preview

Sascha Möllering | zanox AG

Docker in the Cloud

About me

Sascha Möllering

[email protected]

[email protected]

Lead Engineer / DevOps Hipster

zanox AG

http://autoscaling.io

@sascha242

About meJava Magazin 11.14

Architektur im Kontext der Cloud: Patterns und Best Practices

AWS Virtual Cloud Summit

Continuous delivery in AWS using Docker

http://aws-summit.de/

Entwickler Spezial: Docker

Über den Wolken: Ein Erfahrungsbericht zum Docker-Einsatz in der Amazon Cloud

Agenda

• Problem?

• Real World example

• Docker implementations

• Deployment

• Q&A

Problem?

• Using different Cloud providers

• Additionally: own DC• Different

infrastructure• Different

deployment mechanisms

Solution!

• Different applications!

• For each deployment target -> different package!

• One container to rule them all!

• Application detects deployment target

• Application uses specific infrastructure

Real Solution!

Real World example

• JVM based event-driven application

• Ingests data into bus system

• Uses Redis as a cache

• Base framework is Vert.x

• Pre-build Docker image

Real World example

Real World example

• Deployment targets:– Own data center– Amazon Web Services– Microsoft Azure

Real World example

• Our own data center:– Linux servers with Docker 1.6– Apache Kafka 0.8.1/0.8.2

• Topics and partitions• Easy to write, hard to read from

– Redis 2.8

Real World example

• Amazon Web Services:– EC2 instance with Docker 1.6– Amazon Kinesis

• Amazon’s implementation of Kafka (?)• Streams and shards• KCL does the heavy lifting

– ElastiCache with Redis engine• Amazon’s implementation of Redis

Real World example

• Microsoft Azure:– Azure Ubuntu VM with Docker 1.6– Azure Service Bus

• Bus system in Azure• AMQP and JMS• Problem: no partitioning for Java

– Azure Cache• Redis implementation in Azure

Real World example

• For Redis: Jedis client in all cases

• Difference: bus system– mod-kafka– mod-kinesis– mod-service-bus

Real World example

• mod-kafka:– Vert.x module for Apache Kafka– Recieves events by other verticles– Sends events to Kafka broker– Either Strings or binary data– Supports StatsD– Based on Apache Kafka Java API

Real World example

• mod-kinesis:– Vert.x module for Amazon Kinesis– Recieves events by other verticles– Sends events to Kinesis stream– Either Strings or binary data– Support for partitioning in events– Based on AWS Java SDK

Real World example

• mod-service-bus:– Vert.x module for Azure Service Bus– Recieves events by other verticles– Support for binary data only ATM– No partitioning (Service Bus problem)– Based on AMQP and JMS

Real World example

But … how can we detect where the application is running?

Real World example

http://169.254.169.254/latest/meta-data

Real World example

boolean isAzure = true;

try { RoleEnvironment.getRoles();

} catch (Exception exc) { isAzure = false;}

Real World example

• Problem: not working in Docker container• Alternative: check for /etc/waagent.conf• File has to be mapped in Docker container

Real World example

• StarterVerticle pattern:– Bootstrapping Vert.x application– Start all verticles in StarterVerticle– Deploy all modules in StartVerticle

Real World example

Docker implementations

Docker implementations

• Basic implementation:– EC2 using User Data– Install Docker and start service– Either pull Container in User Data script – Or Remote API

Docker implementations

• AWS OpsWorks:– No “official” support– Docker Chef Cookbook by AWS – Problem: Docker Images are build in the

Cookbook

Docker implementations

• Amazon Elastic Beanstalk:– Support for single/multi container

environments– ELB support on container level– Multi container environments -> ECS

resources – Running containers locally is possible

Docker implementations

• Amazon EC2 Container Service:– Container management service for Docker– Description language for applications (“task

definition”)– Supports batch mode (taks that only run

once)– Supports long running taks– ELB support on container level

Docker implementations

Docker implementations

• xplat-cli:– Support for:

• Ubuntu from Azure Image Gallery• Custom Linux image with Azure Linux VM

Agent

– Similar to plain EC2 approach

Docker implementations

• xplat-cli:– azure vm docker create– Docker remote API

Deployment

Deployment

Amazon Cloud

WorkstationGitHub Jenkins

Python/Boto

Docker Image

Docker Registry S3 bucket withDocker Images

Deployment

Deployment

Deployment

• AWS OpsWorks:– Docker Chef Cookbook by AWS – Add a new stack containing the Cookbook– Add a new layer and add custom recipes– Docker Images are build in the Cookbook– Use custom JSON to modify stack

configuration

Deployment

• Amazon Elastic Beanstalk:– Create an application using console or CLI– Create Dockerrun.aws.json to deploy a

Docker container– Create a ZIP-file containing application

files (optional)

Deployment

1. Create a cluster

2. Create a task definition

3. Create a service

4. Configure cluster

5. Run task

Deployment

Deployment

• Remote API is exposed

docker --tls -H tcp://<vm-name-you-used>.cloudapp.net:4243 info

Deployment

• Useful Docker clients:– Spotify Docker Client– docker-py

Deployment

Deployment

Q&A