Docker Swarm: Real Life Use Case

@ Docker Meetup Madrid

By Emmet O'Grady / @emmetogrady

Overview

  • The Teams Workflow (why swarm?)
  • Showcase the Swarm
  • Automating the deploy (and obstacles)

Aim: Show you how to automate docker (it has it's quirks)

About Me

  • DevOps Engineer in Suntransfers
  • PHP before that
  • Docker fan :)
  • My personal server is a docker swarm
  • Author of a docker course on Udemy (another in progress)

About Suntransfers

  • Pre-book taxi's between airports and hotels
  • Company is ~9 years old
  • 10 technical (2 sys, the rest PHP, JS and design)
  • Office in Barcelona with ~50 people

Our Workflow

  • PR based (we use Github)
  • We deploy each Pull Request (PR) to PRE for automatic testing (and manual if needed)

Introducing PRE (our swarm)

PRE Architecture

A single (for now) server with Docker 1.13

A wildcard DNS (*.pre.suntransfers.biz) pointing to it

jwilder/nginx-proxy running on it (as a service)

jwilder/nginx-proxy

Deploy

Let's look at some real code:

Monitoring

Obstacles

  • Swarm create/update commands were not idempotent (until docker 1.13)
  • Bug where image was not updated unless tag changed (fixed in docker ~1.12.3)
  • jwilder/nginx-proxy does not support multi-host swarm mode -> use traefik or similar instead
  • Storage drivers caused problems (disk filling up, unrecoverable space) -> currently using overlay2 on ubuntu

Jenkins

Jenkins

Jenkins receives the webhook from Github

Jenkins parses the webhook like this (it's code).

Let's look at the Jenkins jobs

NimbleCI

nimbleci.com

  • Builds each PR
  • Pushes tag to the repo
  • Webhook triggers next steps in Jenkins
  • Tag is "promoted" when PR is closed

Wrapping Up

We talked about:

  • PRE, what it is, why we needed it, it's bits
  • Some problems with automating workflows (most are solved by 1.13)
  • Our teams workflow and steps in CI

Questions?

Twitter: @emmetogrady