Clustering with Docker Swarm

Alexander Zeitler

@alexzeitler_

alexander.zeitler@pdmlab.com

Docker ecosystem

Docker Engine

Docker Compose

Docker Machine

Docker Swarm

Docker Hub

Docker Registry

Docker Cloud

Swarm

  • Native (from Docker, Inc.)
  • Clusters Dockers hosts in a large pool
  • Simplified management at scale

Alternatives

  • Kubernetes
  • Mesosphere
  • Apache Mesos
  • ...

Docker Architecture

Client / Server

Docker Server

(Daemon)

Docker Client

(CLI)

TCP 2375/76

Docker API ≈ Swarm API

Scaling is hard

Scaling with Swarm

Swarm Manager

  • Cluster administration
  • Executes Docker commands
  • HA possible
    • 1 Primary
    • n Secondaries

Discovery Service

  • Key/Value store
  • Cluster config / state
  • Mandatory for Swarm
  • HA possible
  • Rebuild
    • Swarm
    • !Network
  • Consul
  • etcd
  • ZooKeeper

Swarm Manager

Discovery Service

P

P

P

S

S

S

S

P

P

S

P

P

P

S

S

S

S

P

P

S

Filtering - e.g. "Production"

Filtering

Affinity

 

  • Image
  • Container

Constraint

 

  • Standard
    • docker info
  • Custom
    • tagged daemons
    • VPC, AZ
    • Blue/Green
    • etc.

 

Resource

 

Availability of

Resources

 

  • Network
  • RAM
  • CPU
  • etc.

P

P

P

S

S

S

S

P

P

S

Scheduling

Scheduling

Random

 

  • Debugging
  • Production?

BinPack

CPU/RAM

  • !Spread
  • Smallest node first
  • Stopped containers considered
  • Use as less infrastructure as possible
  • Production!

Spread

CPU/RAM

  • Default
  • Balanced deployment (if CPU/RAM is ok)
  • Daemon with the least containers first
  • Stopped containers considered
  • Production!

Scheduling

One Strategy / Swarm Cluster

Building the Infrastructure

HA for Swarm Manager

Put it in different VMs

Put VMs in different Hosts

Put Hosts in different Racks

Connect Hosts to different Access Layer Switches

Put Racks in different Halls / DC

 

Avoid single points of failure

Swarm Manager

Discovery Service

Client / CLI

3375/76

2376

8500

2376

8500

Node 1

Node 2

Node 3

Demo

Questions

Thanks!

Clustering with Docker Swarm

By Alexander Zeitler

Clustering with Docker Swarm

  • 935