the age of orchestration: from docker basics to cluster management

39
The age of orchestration NICOLA PAOLUCCI DEVELOPER INSTIGATOR ATLASSIAN @DURDN From Docker basics to cluster management

Upload: nicola-paolucci

Post on 06-Jan-2017

1.251 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: The age of orchestration: from Docker basics to cluster management

The age of orchestration

NICOLA PAOLUCCI • DEVELOPER INSTIGATOR • ATLASSIAN • @DURDN

From Docker basics to cluster management

Page 2: The age of orchestration: from Docker basics to cluster management

2

Time me and ring a bell if I am over it. Just kidding I’ll be over by a bit but it’s ok. We’re friends.

Three minute Docker intro?

Page 3: The age of orchestration: from Docker basics to cluster management

3

BINS/LIBS

GUEST OS

HYPERVISOR

HOST OS

SERVER

ROBUST MONOLITHIC

SLOW TO BOOT HEAVY

OVERHEAD

APP A

BINS/LIBS

GUEST OS

APP B

DEFINITIONS

Traditional Virtual Machines

Page 4: The age of orchestration: from Docker basics to cluster management

4

DOCKER ENGINE

HOST OS

SERVER

LEAN LIGHTWEIGHT

ISOLATED PORTABLE EFFICIENT

BINS/LIBS

APP A

BINS/LIBS

APP B

DEFINITIONS

Docker Containers

Page 5: The age of orchestration: from Docker basics to cluster management

5

DEFINITIONS

Seen from another angle, the core of Docker is four distinct things

Clearly defined interfaces

Central registry of ready images

Caching mechanism to re-use steps

A standard format to package applications

Page 6: The age of orchestration: from Docker basics to cluster management

6

DO WE USE IT?

We have embraced Docker on two fronts

For our internal PaaS In our productsNOT PART OF THIS

SESSION

Page 7: The age of orchestration: from Docker basics to cluster management

@durdn

Our internal PaaS, called Micros

Page 8: The age of orchestration: from Docker basics to cluster management

8

File infrastructure numbers

Microservices

8

8

Page 9: The age of orchestration: from Docker basics to cluster management

9

File infrastructure numbers

Containers spun per conversion

5

9

Page 10: The age of orchestration: from Docker basics to cluster management

10

File infrastructure numbers

Containers spun per month

M6

10

Page 11: The age of orchestration: from Docker basics to cluster management

@durdn

Page 12: The age of orchestration: from Docker basics to cluster management

@durdn

Orchestration is the next arena

Page 13: The age of orchestration: from Docker basics to cluster management

What’s Orchestration?

13

Services YOUR APPLICATION

Orchestration FRAMEWORKS

Data Center PHYSICAL INFRA

Page 14: The age of orchestration: from Docker basics to cluster management

What’s Orchestration?

13

Services YOUR APPLICATION

Orchestration FRAMEWORKS

Data Center PHYSICAL INFRA

Page 15: The age of orchestration: from Docker basics to cluster management

@durdn

Page 16: The age of orchestration: from Docker basics to cluster management

@durdn

Page 17: The age of orchestration: from Docker basics to cluster management

@durdn

Page 18: The age of orchestration: from Docker basics to cluster management

17

Page 19: The age of orchestration: from Docker basics to cluster management

18

Docker’s Own Orchestration Tools

Docker machine Docker compose Docker swarm Docker network

Page 20: The age of orchestration: from Docker basics to cluster management

Where is the DEMO Lebowski?

Page 21: The age of orchestration: from Docker basics to cluster management

20

TOOL NR.1

Docker machine

Simple command line tool to provision local and remote hosts with Docker installed. Fantastic to get up and running fast. It has drivers for many Internet service providers and PaaS.

Docker machine

$ docker-machine create -d virtualbox dev

INFO[0000] Downloading boot2docker.iso from... INFO[0001] Creating SSH key... INFO[0001] Creating VirtualBox VM... INFO[0006] Starting VirtualBox VM... INFO[0007] Waiting for VM to start... INFO[0041] "dev" has been created and is now active

Page 22: The age of orchestration: from Docker basics to cluster management

• Provision a machine with Docker installed and ready

• Pull a minimal image• Run a few docker commands• Tear down the machine

Docker machine DEMO

$ docker-machine create -d virtualbox dev

INFO[0000] Downloading boot2docker.iso from... INFO[0001] Creating SSH key... INFO[0001] Creating VirtualBox VM... INFO[0006] Starting VirtualBox VM... INFO[0007] Waiting for VM to start... INFO[0041] "dev" has been created and is now active

Page 23: The age of orchestration: from Docker basics to cluster management

• “docker-machine create” to provision the host, locally or remotely• “docker-machine ls” to list the machines• “docker-machine stop/rm” to stop and remove

Recap of what you saw

$ docker-machine create -d virtualbox dev

INFO[0000] Downloading boot2docker.iso from... INFO[0001] Creating SSH key... INFO[0001] Creating VirtualBox VM... INFO[0006] Starting VirtualBox VM... INFO[0007] Waiting for VM to start... INFO[0041] "dev" has been created and is now active

Page 24: The age of orchestration: from Docker basics to cluster management

24

TOOL NR.2

Docker compose

Docker compose

Describe the relation of your components in a simple YAML file called docker-compose.yml and docker-compose takes care of starting them and linking them in order.

1 stash:

2 image: atlassian/stash

3 ports:

4 - "7990:7990"

5 - "7999:7999"

6 volumes:

7 - /root/orchestration/stash-data:/var/atlassian/application-data/stash

8 links:

9 - db

10 user: root

11 privileged: true

12 db:

13 image: postgres

14 environment:

15 POSTGRES_PASSWORD: somepassword

Page 25: The age of orchestration: from Docker basics to cluster management

• Provision a machine on a PaaS• Pull PostgreSQL and a Java

app from the Registry• Use Compose to start the app• Tear down the machine

Docker compose DEMO

$ docker-compose up -d

Page 26: The age of orchestration: from Docker basics to cluster management

• “docker-machine create” to provision the host• Edit “docker-compose.yml” to describe our app• “docker-compose up -d” to start our application• “docker-machine rm compose-demo“ to

remove it

Recap of what you saw

$ docker-compose up -d

Page 27: The age of orchestration: from Docker basics to cluster management

28

TOOL NR.3

Docker swarm

Deploy images and run containers on a full clusters as if you’re handling a single machine

Docker swarm

$ docker pull swarm

$ docker run --rm swarm create 6856663cdefdec325839a4b7e1de38e8

Page 28: The age of orchestration: from Docker basics to cluster management

@durdn

Docker swarmswarm master

swarm node swarm node swarm node

container

container

container

container

container

container

discovery service

High level architecture

scheduler

Page 29: The age of orchestration: from Docker basics to cluster management

• Strategies• Spread• Binpack• Random

• Filters• Constraint• Affinity• Port• Dependency• Health

Swarm comes with strategies and filters

$ docker run -e \ constraint:instance==database --name db

Page 30: The age of orchestration: from Docker basics to cluster management

• Provision a Docker swarm• Made up of three hosts

• Master node• Node with 2gb of RAM• simple Node

• Use labels to deploy to nodes• Run Java app and PostgreSQL

on different nodes

The plan for the Swarm DEMO

$ docker pull swarm

$ docker run --rm swarm create 6856663cdefdec325839a4b7e1de38e8

Page 31: The age of orchestration: from Docker basics to cluster management

@durdn

After Step 1demo-master

node-1 node-2

label: java

discovery service

Current Architecture

scheduler

RAM: 2GB

label: database

RAM: 512MB

Page 32: The age of orchestration: from Docker basics to cluster management

@durdn

After Step 2demo-master

node-1 node-2

label: java

discovery service

Current Architecture

scheduler

RAM: 2GB

label: database

RAM: 512MB

PostgreSQL

Page 33: The age of orchestration: from Docker basics to cluster management

@durdn

After Step 3demo-master

node-1 node-2

label: java

discovery service

Current Architecture

scheduler

RAM: 2GB

label: database

RAM: 512MB

PostgreSQLJava App

Page 34: The age of orchestration: from Docker basics to cluster management

• We created a 3-node cluster with “docker-machine”

• We tagged the nodes with labels• We started our components using

label constraints and not machine names

Recap of Swarm DEMO

$ docker pull swarm

$ docker run --rm swarm create 6856663cdefdec325839a4b7e1de38e8

Page 35: The age of orchestration: from Docker basics to cluster management

39

COROLLARY

Docker Java Images Are Big

The default Java image is 800+MB ?!

$ docker pull java

REPOSITORY IMAGE ID VIRTUAL SIZE java 5282faca75e8 817.6 MB

Page 36: The age of orchestration: from Docker basics to cluster management

• Alpine Linux provides a minimal container image of 5MB

• It includes BusyBox and a package manager

• OpenJDK 7 is already on it…• Resulting in a 123MB Java image

Start with a smaller base image

FROM alpine:3.2 RUN apk --update add openjdk7-jre CMD ["/usr/bin/java", "-version"]

Page 37: The age of orchestration: from Docker basics to cluster management

For Oracle Java 8 you have to roll it your own

http://bit.do/minimal-java

Page 38: The age of orchestration: from Docker basics to cluster management

I hope you are hyped as I am for all this coolness, come

talk to me afterwards!

Page 39: The age of orchestration: from Docker basics to cluster management

Thank you!

NICOLA PAOLUCCI • DEVELOPER INSTIGATOR • ATLASSIAN • @DURDN

Twitter: @durdn