SlideShare a Scribd company logo
NICOLA PAOLUCCI • ATLASSIAN • @DURDN
Higher Order Infrastructure
Micro-services on the Docker Swarm
Docker brought to the average software developer
Clear interfaces
i.e. which ports to open
A standard format
To package cloud applications
A caching layer
To re-use building blocks
Central registry
To store images
What’s Orchestration?
3
Services
YOUR APPLICATION
Orchestration
FRAMEWORKS
Data Center
PHYSICAL INFRA
The advent of the Docker orchestration ecosystem
Easier upgrade and roll-out
Because of immutable infrastructure, container
registries even in heavily polyglot applications
Easier to reason about
We can use high level domain specific
languages (like Docker compose’s YAML) to
describe the relationships of our application
Baked in scalability and HA
Orchestration frameworks provide a solid base
to make your application easily scale and be
highly available
Is transforming the way we think about and deploy to the cloud
So let’s deploy a Polyglot
Application Stack
Excitement
Even more excitement
Demo Disclaimer
In order to convey concepts, the Demo
will show a simplified scenario. Unless
you, fine audience are all DevOps gods,
in which case: Are you here just to mock
me?!
Sample Polyglot Application: a voting platform
Reverse Proxy
Voting App
Results App
User from the
Internet
Sample Polyglot Application: a voting platform
SQL database
key/value store
Worker
Python
NodeJS
Java
Components of the orchestration puzzle
In Docker’s own ecosystem
Provision machines
Configure and prepare machines
to run Docker on a number of
IaaS providers. Optionally
configuring them to be swarm
cluster ready
Define services
Define and link services together
at a high level, without specifying
low level infrastructure
information
Manage the nodes
Allocate services to the cluster
nodes, restart policies, where to
deploy workloads depending on
requirements
Networks & volumes
Automatic overlay networks and
cross-cluster volumes are critical
to complete the puzzle
Docker machine Docker compose Docker swarm Docker network et al.
Other supporting components are…
Discovery service
we’ll use Consul
Reverse Proxy
Otherwise called load balancer
Volume managers
Out of scope for this talk
Other concerns
Cloud infra is hard!
And more of them
You’re not supposed to read this
Distributed Logging
Kibanas of the world
swarm-master
Discovery service
Shared Swarm VXLAN Overlay network
Entry point fixed IP address
User from the
Internet
Simplified architecture to support our app: machines
Swarm master
consul
database
db
Reverse proxy
reverse-proxy
Services
services
A word about Docker Swarm
15
CLUSTER MANAGER
Docker swarm
Deploy images and run containers on a full
clusters as if you’re handling a single machine
Docker swarm
$ docker run -e 
constraint:instance==database 
--name db
swarm master
swarm node swarm node swarm node
container
container
container
container
container
container
discovery service
scheduler
Docker Swarm: Architecture
17
HELPER TOOL
Discovery Service
For our Swarm to know which nodes are
added to the infrastructure and store
information about them we need to use a key-
value discovery service, like Consul.
Consul from HashiCorp
We need to setup the physical
infra, we’ll use Docker machine
19
FIRST STEP
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 IaaS.
Docker machine
$ docker-machine create -d v
INFO[0000] Downloading boot2
INFO[0001] Creating SSH key.
INFO[0001] Creating VirtualB
INFO[0006] Starting VirtualB
INFO[0007] Waiting for VM to
INFO[0041] "dev" has been cr
Choose a provider
How to provision a box with docker-machine
Choose requirements Name it and label it
Docker machine has drivers to
provision hosts on a wide variety of
IaaS platforms
Base image, memory, geographical
area
Give it a name and choose labels to
assign to the machine
docker-machine create -d digitalocean 
--digitalocean-access-token=$DO_TOKEN 
--digitalocean-region "ams3" 
consul
$
Specify the discovery service
Creating a machine part of the Swarm
Specify it’s part of the swarm Name it
Docker machine has drivers to
provision hosts on a wide variety of
IaaS platforms
Base image, memory, geographical
area
Give it a name
docker-machine create -d digitalocean 
[...]
--digitalocean-image "debian-8-x64" 
--digitalocean-region "ams3" 
--swarm --swarm-master 
--swarm-discovery=consul://$(docker-machine ip consul):8500 
--engine-opt="cluster-store=consul://$(docker-machine ip consul):8500" 
--engine-opt="cluster-advertise=eth0:2376" 
cluster
$
After all the provisioning we have
$ docker-machine ls
cluster digitalocean Running tcp://178.62.222.186:2376 cluster (master) v1.11.0
consul digitalocean Running tcp://178.62.242.131:2376 v1.11.0
db digitalocean Running tcp://128.199.39.208:2376 cluster v1.11.0
rproxy digitalocean Running tcp://128.199.60.17:2376 cluster v1.11.0
services digitalocean Running tcp://128.199.62.119:2376 cluster v1.11.0
In Digital Ocean UI
swarm-master
Reverse proxy
Discovery service
Shared Swarm VXLAN Overlay network
Entry point fixed IP address
User from the
Internet
Simplified architecture to support our app: machines
rproxy
Swarm master
consul
database
db
Services
services
• Strategies
• Spread
• Binpack
• Random
• Filters
• Constraint
• Affinity
• Port
• Dependency
• Health
Swarm comes with strategies and filters
$ docker run -e 
constraint:instance==database --name db
Worker
Java
Voting App
Python
Results App
NodeJS
swarm-master
Reverse proxy
Discovery service
Shared Swarm VXLAN Overlay network
Entry point fixed IP address
User from the
Internet
What Orchestration should do for us…
reverse-proxy
Swarm master
consul
Database
db
Services
services
We need to link our components
across the cluster
29
TOOL NR.3
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 bitbucket:
2 image: atlassian/bitbucket-server
3 ports:
4 - "7990:7990"
5 - "7999:7999"
6 links:
7 - db
8 volumes_from:
9 - license
10 user: root
11 privileged: true
12 db:
13 image: postgres
14 ports:
15 - "5432:5432"
16 environment:
17
18 license:
19 build: .
Dive into Compose configuration
Where is the image
docker-compose.yml a declarative way to define services
Ports and dependencies
Filters and affinities
Specify where is the image or at
which folder the sources reside
Define which ports the application
exposes and which other
containers it depends upon
Specify filters, affinities and
environment variables to tell the
Swarm master where to deploy this
specific service
version: “2”
services:
voting-app:
build: ./voting-app/.
image: docker.atlassian.io/npaolucci/voting-app
ports:
- "80"
depends_on:
- redis
environment:
- "constraint:instance==service"
- "VIRTUAL_HOST=vote.cluster.local"
result-app:
Constraints are powerful
docker-compose.yml a declarative way to define services
Load environment file
We can deploy containers based on
labels, node names, affinity rules or
hardware characteristics
To pass environment variables to
docker-compose you can load up
an external environment variables
file
version: “2”
services:
result-app:
build: ./result-app/.
image: docker.atlassian.io/npaolucci/result-app
ports:
- "80"
depends_on:
- db
environment:
- "constraint:instance==service"
- "VIRTUAL_HOST=results.cluster.local"
worker:
docker-compose.yml a declarative way to define services
services:
worker:
build: ./worker
image: docker.atlassian.io/npaolucci/worker
depends_on:
- redis
- db
environment:
- "constraint:instance==service"
redis:
image: redis
docker-compose.yml a declarative way to define services
services:
redis:
image: redis
ports:
- "6379:6379"
environment:
- "constraint:node==db"
services:
db:
image: postgres:9.4
volumes:
- "db-data:/var/lib/postgresql/data"
environment:
- "constraint:node==db"
volumes:
db-data:
Worker
Voting App
Results App
swarm-master
Reverse proxy
Discovery service
Shared Swarm VXLAN Overlay network
Entry point fixed IP address
User from the
Internet
What Orchestration should do for us…
reverse-proxy
Swarm master
consul
Database
db
Services
services
Load environment file
You can’t execute commands in the
YAML. To pass environment
variables to docker-compose you
can use an file
Setting up the Reverse Proxy
services:
proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
env_file:
- proxy.env
volumes:
- "/tmp/docker-certs:/tmp/docker-certs"
cat proxy.env
DOCKER_HOST=tcp://178.62.222.186:3376
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/tmp/docker-certs
constraint:node==rproxy
nginx-proxy
Takes dynamically listens for containers
exposing the right port and defining a
VIRTUAL_HOST variable and refreshes
nginx upstreams
Where is the DEMO
Lebowski?
What about scaling?
Docker orchestration ecosystem has greatly matured
Compose improvements
Like support for custom overlay networks, first
class volumes and better support for Swarm
Swarm rescheduling on failure
While the “--restart” flag has been there for a
while the most recent Swarm release has
rescheduling on node failure. A welcome
feature that was missing.
Docker rewritten to use runC
And the first deliverables of the Open Container
Initiative
In the past few releases
@durdn on Twitter
Thank you!

More Related Content

PDF
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
PPTX
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
PPTX
Terraform Modules Restructured
PPT
Real-Time Streaming with Apache Spark Streaming and Apache Storm
PPTX
Infrastructure as code, using Terraform
PDF
Terraform: Configuration Management for Cloud Services
PPT
Introduction to apache_cassandra_for_develope
PDF
ecs-presentation
Making your elastic cluster perform - Jettro Coenradie - Codemotion Amsterdam...
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
Terraform Modules Restructured
Real-Time Streaming with Apache Spark Streaming and Apache Storm
Infrastructure as code, using Terraform
Terraform: Configuration Management for Cloud Services
Introduction to apache_cassandra_for_develope
ecs-presentation

What's hot (20)

PDF
Big Data Day LA 2015 - Sparking up your Cassandra Cluster- Analytics made Awe...
PDF
Real Time Data Streaming using Kafka & Storm
PDF
Terraform in action
PDF
How to create aws s3 bucket using terraform
PDF
Multi-Region Cassandra Clusters
PDF
Fact-Based Monitoring - PuppetConf 2014
PDF
Python and cassandra
PPT
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
PPTX
Monitoring Docker containers - Docker NYC Feb 2015
PDF
Building infrastructure with Terraform (Google)
PPTX
Effective terraform
PDF
Buzzwords 2014 / Overview / part1
KEY
Scaling Twitter with Cassandra
PDF
Terraform
PDF
Terraform: An Overview & Introduction
PPTX
Big data lambda architecture - Streaming Layer Hands On
PDF
Cassandra Summit 2014: Novel Multi-Region Clusters — Cassandra Deployments Sp...
PDF
Real-time streams and logs with Storm and Kafka
PDF
London Hug 19/5 - Terraform in Production
ODP
Introduction to apache_cassandra_for_developers-lhg
Big Data Day LA 2015 - Sparking up your Cassandra Cluster- Analytics made Awe...
Real Time Data Streaming using Kafka & Storm
Terraform in action
How to create aws s3 bucket using terraform
Multi-Region Cassandra Clusters
Fact-Based Monitoring - PuppetConf 2014
Python and cassandra
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Monitoring Docker containers - Docker NYC Feb 2015
Building infrastructure with Terraform (Google)
Effective terraform
Buzzwords 2014 / Overview / part1
Scaling Twitter with Cassandra
Terraform
Terraform: An Overview & Introduction
Big data lambda architecture - Streaming Layer Hands On
Cassandra Summit 2014: Novel Multi-Region Clusters — Cassandra Deployments Sp...
Real-time streams and logs with Storm and Kafka
London Hug 19/5 - Terraform in Production
Introduction to apache_cassandra_for_developers-lhg
Ad

Viewers also liked (20)

PDF
Cyber Analysts: who they are, what they do, where they are - Marco Ramilli - ...
PDF
Lo sviluppo di Edge Guardian VR - Maurizio Tatafiore - Codemotion Milan 2016
PPTX
Master the chaos: from raw data to analytics - Andrea Pompili, Riccardo Rossi...
PPTX
DevOps in Cloud, dai Container all'approccio Codeless - Gabriele Provinciali,...
PDF
Milano Chatbots Meetup - Vittorio Banfi - Bot Design - Codemotion Milan 2016
PDF
Games of Simplicity - Pozzi; Molinari - Codemotion Milan 2016
PDF
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
PDF
Come rendere il proprio prodotto una bomba creandogli una intera community in...
PDF
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
PDF
Living on the Edge (Service): Bundling Microservices to Optimize Consumption ...
PDF
Build Apps for Apple Watch - Francesco Novelli - Codemotion Milan 2016
PPTX
Search on the fly: how to lighten your Big Data - Simona Russo, Auro Rolle - ...
PDF
Getting started with go - Florin Patan - Codemotion Milan 2016
PDF
The (almost) lost art of Smalltalk - Nikolas Martens - Codemotion Milan 2016
PDF
How To Structure Go Applications - Paul Bellamy - Codemotion Milan 2016
PDF
Developing apps for developing countries - Natalie Pistunovich - Codemotion M...
PDF
How to avoid Go gotchas - Ivan Daniluk - Codemotion Milan 2016
PDF
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
PDF
Progressive Web Apps: trick or real magic? - Maurizio Mangione - Codemotion M...
PPTX
Making your conferences more memorable with Sketchnoting - Linda van der Pal ...
Cyber Analysts: who they are, what they do, where they are - Marco Ramilli - ...
Lo sviluppo di Edge Guardian VR - Maurizio Tatafiore - Codemotion Milan 2016
Master the chaos: from raw data to analytics - Andrea Pompili, Riccardo Rossi...
DevOps in Cloud, dai Container all'approccio Codeless - Gabriele Provinciali,...
Milano Chatbots Meetup - Vittorio Banfi - Bot Design - Codemotion Milan 2016
Games of Simplicity - Pozzi; Molinari - Codemotion Milan 2016
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Come rendere il proprio prodotto una bomba creandogli una intera community in...
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Living on the Edge (Service): Bundling Microservices to Optimize Consumption ...
Build Apps for Apple Watch - Francesco Novelli - Codemotion Milan 2016
Search on the fly: how to lighten your Big Data - Simona Russo, Auro Rolle - ...
Getting started with go - Florin Patan - Codemotion Milan 2016
The (almost) lost art of Smalltalk - Nikolas Martens - Codemotion Milan 2016
How To Structure Go Applications - Paul Bellamy - Codemotion Milan 2016
Developing apps for developing countries - Natalie Pistunovich - Codemotion M...
How to avoid Go gotchas - Ivan Daniluk - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Progressive Web Apps: trick or real magic? - Maurizio Mangione - Codemotion M...
Making your conferences more memorable with Sketchnoting - Linda van der Pal ...
Ad

Similar to Higher order infrastructure: from Docker basics to cluster management - Nicola Paolucci - Codemotion Amsterdam 2016 (20)

PDF
Paolucci voxxed-days-berlin-2016-age-of-orchestration
PDF
Docker orchestration voxxed days berlin 2016
PDF
Orchestrating Linux Containers while tolerating failures
PDF
Alibaba Cloud Conference 2016 - Docker Enterprise
PDF
The age of orchestration: from Docker basics to cluster management
PDF
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
PPTX
A docker love story
PPTX
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
PPTX
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
PDF
Swarm: Native Docker Clustering
PDF
Building Your Docker Tech Stack
PDF
Building your production tech stack for docker container platform
PDF
New Docker Features for Orchestration and Containers
PPTX
Introduction To Docker, Docker Compose, Docker Swarm
PPTX
So Many Docker Platforms...so little time
PDF
DockerDay2015: Docker orchestration for sysadmin
PDF
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
PPTX
Docker Platform and Ecosystem Nov 2015
PDF
Introduction to Docker and Monitoring with InfluxData
PDF
Deep Dive into Docker Swarm Mode
Paolucci voxxed-days-berlin-2016-age-of-orchestration
Docker orchestration voxxed days berlin 2016
Orchestrating Linux Containers while tolerating failures
Alibaba Cloud Conference 2016 - Docker Enterprise
The age of orchestration: from Docker basics to cluster management
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
A docker love story
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Swarm: Native Docker Clustering
Building Your Docker Tech Stack
Building your production tech stack for docker container platform
New Docker Features for Orchestration and Containers
Introduction To Docker, Docker Compose, Docker Swarm
So Many Docker Platforms...so little time
DockerDay2015: Docker orchestration for sysadmin
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Docker Platform and Ecosystem Nov 2015
Introduction to Docker and Monitoring with InfluxData
Deep Dive into Docker Swarm Mode

More from Codemotion (20)

PDF
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
PDF
Pompili - From hero to_zero: The FatalNoise neverending story
PPTX
Pastore - Commodore 65 - La storia
PPTX
Pennisi - Essere Richard Altwasser
PPTX
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
PPTX
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
PPTX
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
PPTX
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
PDF
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
PDF
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
PDF
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
PDF
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
PDF
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
PDF
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
PPTX
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
PDF
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
PDF
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
PDF
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
PDF
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Pompili - From hero to_zero: The FatalNoise neverending story
Pastore - Commodore 65 - La storia
Pennisi - Essere Richard Altwasser
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
A Presentation on Artificial Intelligence
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation theory and applications.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Modernizing your data center with Dell and AMD
Understanding_Digital_Forensics_Presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
A Presentation on Artificial Intelligence
The AUB Centre for AI in Media Proposal.docx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation theory and applications.pdf
Big Data Technologies - Introduction.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Modernizing your data center with Dell and AMD

Higher order infrastructure: from Docker basics to cluster management - Nicola Paolucci - Codemotion Amsterdam 2016

  • 1. NICOLA PAOLUCCI • ATLASSIAN • @DURDN Higher Order Infrastructure Micro-services on the Docker Swarm
  • 2. Docker brought to the average software developer Clear interfaces i.e. which ports to open A standard format To package cloud applications A caching layer To re-use building blocks Central registry To store images
  • 4. The advent of the Docker orchestration ecosystem Easier upgrade and roll-out Because of immutable infrastructure, container registries even in heavily polyglot applications Easier to reason about We can use high level domain specific languages (like Docker compose’s YAML) to describe the relationships of our application Baked in scalability and HA Orchestration frameworks provide a solid base to make your application easily scale and be highly available Is transforming the way we think about and deploy to the cloud
  • 5. So let’s deploy a Polyglot Application Stack
  • 8. Demo Disclaimer In order to convey concepts, the Demo will show a simplified scenario. Unless you, fine audience are all DevOps gods, in which case: Are you here just to mock me?!
  • 9. Sample Polyglot Application: a voting platform
  • 10. Reverse Proxy Voting App Results App User from the Internet Sample Polyglot Application: a voting platform SQL database key/value store Worker Python NodeJS Java
  • 11. Components of the orchestration puzzle In Docker’s own ecosystem Provision machines Configure and prepare machines to run Docker on a number of IaaS providers. Optionally configuring them to be swarm cluster ready Define services Define and link services together at a high level, without specifying low level infrastructure information Manage the nodes Allocate services to the cluster nodes, restart policies, where to deploy workloads depending on requirements Networks & volumes Automatic overlay networks and cross-cluster volumes are critical to complete the puzzle Docker machine Docker compose Docker swarm Docker network et al.
  • 12. Other supporting components are… Discovery service we’ll use Consul Reverse Proxy Otherwise called load balancer Volume managers Out of scope for this talk Other concerns Cloud infra is hard! And more of them You’re not supposed to read this Distributed Logging Kibanas of the world
  • 13. swarm-master Discovery service Shared Swarm VXLAN Overlay network Entry point fixed IP address User from the Internet Simplified architecture to support our app: machines Swarm master consul database db Reverse proxy reverse-proxy Services services
  • 14. A word about Docker Swarm
  • 15. 15 CLUSTER MANAGER Docker swarm Deploy images and run containers on a full clusters as if you’re handling a single machine Docker swarm $ docker run -e constraint:instance==database --name db
  • 16. swarm master swarm node swarm node swarm node container container container container container container discovery service scheduler Docker Swarm: Architecture
  • 17. 17 HELPER TOOL Discovery Service For our Swarm to know which nodes are added to the infrastructure and store information about them we need to use a key- value discovery service, like Consul. Consul from HashiCorp
  • 18. We need to setup the physical infra, we’ll use Docker machine
  • 19. 19 FIRST STEP 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 IaaS. Docker machine $ docker-machine create -d v INFO[0000] Downloading boot2 INFO[0001] Creating SSH key. INFO[0001] Creating VirtualB INFO[0006] Starting VirtualB INFO[0007] Waiting for VM to INFO[0041] "dev" has been cr
  • 20. Choose a provider How to provision a box with docker-machine Choose requirements Name it and label it Docker machine has drivers to provision hosts on a wide variety of IaaS platforms Base image, memory, geographical area Give it a name and choose labels to assign to the machine docker-machine create -d digitalocean --digitalocean-access-token=$DO_TOKEN --digitalocean-region "ams3" consul $
  • 21. Specify the discovery service Creating a machine part of the Swarm Specify it’s part of the swarm Name it Docker machine has drivers to provision hosts on a wide variety of IaaS platforms Base image, memory, geographical area Give it a name docker-machine create -d digitalocean [...] --digitalocean-image "debian-8-x64" --digitalocean-region "ams3" --swarm --swarm-master --swarm-discovery=consul://$(docker-machine ip consul):8500 --engine-opt="cluster-store=consul://$(docker-machine ip consul):8500" --engine-opt="cluster-advertise=eth0:2376" cluster $
  • 22. After all the provisioning we have $ docker-machine ls cluster digitalocean Running tcp://178.62.222.186:2376 cluster (master) v1.11.0 consul digitalocean Running tcp://178.62.242.131:2376 v1.11.0 db digitalocean Running tcp://128.199.39.208:2376 cluster v1.11.0 rproxy digitalocean Running tcp://128.199.60.17:2376 cluster v1.11.0 services digitalocean Running tcp://128.199.62.119:2376 cluster v1.11.0
  • 24. swarm-master Reverse proxy Discovery service Shared Swarm VXLAN Overlay network Entry point fixed IP address User from the Internet Simplified architecture to support our app: machines rproxy Swarm master consul database db Services services
  • 25. • Strategies • Spread • Binpack • Random • Filters • Constraint • Affinity • Port • Dependency • Health Swarm comes with strategies and filters $ docker run -e constraint:instance==database --name db
  • 26. Worker Java Voting App Python Results App NodeJS swarm-master Reverse proxy Discovery service Shared Swarm VXLAN Overlay network Entry point fixed IP address User from the Internet What Orchestration should do for us… reverse-proxy Swarm master consul Database db Services services
  • 27. We need to link our components across the cluster
  • 28. 29 TOOL NR.3 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 bitbucket: 2 image: atlassian/bitbucket-server 3 ports: 4 - "7990:7990" 5 - "7999:7999" 6 links: 7 - db 8 volumes_from: 9 - license 10 user: root 11 privileged: true 12 db: 13 image: postgres 14 ports: 15 - "5432:5432" 16 environment: 17 18 license: 19 build: .
  • 29. Dive into Compose configuration
  • 30. Where is the image docker-compose.yml a declarative way to define services Ports and dependencies Filters and affinities Specify where is the image or at which folder the sources reside Define which ports the application exposes and which other containers it depends upon Specify filters, affinities and environment variables to tell the Swarm master where to deploy this specific service version: “2” services: voting-app: build: ./voting-app/. image: docker.atlassian.io/npaolucci/voting-app ports: - "80" depends_on: - redis environment: - "constraint:instance==service" - "VIRTUAL_HOST=vote.cluster.local" result-app:
  • 31. Constraints are powerful docker-compose.yml a declarative way to define services Load environment file We can deploy containers based on labels, node names, affinity rules or hardware characteristics To pass environment variables to docker-compose you can load up an external environment variables file version: “2” services: result-app: build: ./result-app/. image: docker.atlassian.io/npaolucci/result-app ports: - "80" depends_on: - db environment: - "constraint:instance==service" - "VIRTUAL_HOST=results.cluster.local" worker:
  • 32. docker-compose.yml a declarative way to define services services: worker: build: ./worker image: docker.atlassian.io/npaolucci/worker depends_on: - redis - db environment: - "constraint:instance==service" redis: image: redis
  • 33. docker-compose.yml a declarative way to define services services: redis: image: redis ports: - "6379:6379" environment: - "constraint:node==db" services: db: image: postgres:9.4 volumes: - "db-data:/var/lib/postgresql/data" environment: - "constraint:node==db" volumes: db-data:
  • 34. Worker Voting App Results App swarm-master Reverse proxy Discovery service Shared Swarm VXLAN Overlay network Entry point fixed IP address User from the Internet What Orchestration should do for us… reverse-proxy Swarm master consul Database db Services services
  • 35. Load environment file You can’t execute commands in the YAML. To pass environment variables to docker-compose you can use an file Setting up the Reverse Proxy services: proxy: image: jwilder/nginx-proxy ports: - "80:80" env_file: - proxy.env volumes: - "/tmp/docker-certs:/tmp/docker-certs" cat proxy.env DOCKER_HOST=tcp://178.62.222.186:3376 DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=/tmp/docker-certs constraint:node==rproxy nginx-proxy Takes dynamically listens for containers exposing the right port and defining a VIRTUAL_HOST variable and refreshes nginx upstreams
  • 36. Where is the DEMO Lebowski?
  • 38. Docker orchestration ecosystem has greatly matured Compose improvements Like support for custom overlay networks, first class volumes and better support for Swarm Swarm rescheduling on failure While the “--restart” flag has been there for a while the most recent Swarm release has rescheduling on node failure. A welcome feature that was missing. Docker rewritten to use runC And the first deliverables of the Open Container Initiative In the past few releases