Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker Swarm - Online Meetup [#SwarmWeek Edition]

Docker Swarm - Online Meetup [#SwarmWeek Edition]

Victor Vieux

March 10, 2016
Tweet

More Decks by Victor Vieux

Other Decks in Technology

Transcript

  1. Swarm in a nutshell • Exposes several Docker Engines as

    a single virtual Engine • Serves the standard Docker API • Extremely easy to get started • Batteries included but swappable
  2. Setup using the hosted discovery service /!\ Not to be

    used in production, for testing only /!\ • Create a cluster: $ swarm create • Add nodes to a cluster: $ swarm join --advertise=<engine_ip>:<engine_port> token://<token> • Start Swarm $ swarm manage <…> token://<token>
  3. Setup using your own K/V store • Add nodes to

    a cluster: $ swarm join --advertise=<engine_ip>:<engine_port> \ consul://<ip_consul>:<port_consul> • Start Swarm $ swarm manage <…> consul://<ip_consul>:<port_consul> You can also use etcd or zookeeper
  4. Setup using a file (static list of nodes) • Add

    nodes to the file: $ echo 10.0.0.1:2375 > my_cluster $ echo 10.0.0.2:2375 >> my_cluster $ echo 10.0.0.3:2375 >> my_cluster • Start Swarm $ swarm manage <…> file://my_cluster
  5. Setup using your own K/V store • Configure networking on

    engine $ docker daemon --cluster-advertise=<engine_ip>:<engine_port> \ --cluster-store=consul://<ip_consul>:<port_consul> • Start Swarm $ swarm manage <…> --discovery-opt kv.path=docker/docker \ consul://<ip_consul>:<port_consul> You can also use etcd or zookeeper
  6. Resource Management • Memory $ docker run -m 1g …

    • CPU $ docker run -c 1 … • Ports $ docker run -p 80:80 …
  7. Constraints • Standard constraints induced from docker info docker run

    -e “constraint:operatingsystem==*fedora*” … docker run -e “constraint:storagedriver==*aufs*” … • Custom constraints with host labels docker daemon --label “region=us-east” docker run -e “constraint:region==us-east” … • Pin a container to a specific host docker run –e “constraint:node==node-2” …
  8. Affinities • Containers affinities docker run --name web nginx docker

    run -e “affinity:container==web” logger • Containers Anti-affinities docker run --name redis-master redis docker run --name redis-slave -e “affinity:container!=redis*” … • Images affinities docker run -e “affinity:image==redis” redis
  9. Soft Affinities/Constraints • Soft Contraints docker run -e “constraint:operatingsystem==~*fedora*” …

    docker run -e “constraint:region==~us-east” … • Soft Affinities docker run --name redis-master redis docker run --name redis-slave -e “affinity:container!=~redis*” …
  10. Swarm Scheduler 2 steps: • 1- Apply filters to exclude

    nodes - ports - constraints - affinity - health - dependency • 2- Use a strategy to rank and pick the best node - binpack - spread - random
  11. Improved node management: docker info Nodes: 3 (unknown): 10.0.0.9:2375 …

    ʦ Status: Pending node-1: 10.0.0.1:2375 ʦ Status: Unhealthy … ʦ Error: Cannot connect to the docker engine endpoint ʦ UpdatedAt: 2016-02-09T19:52:56Z node-2: 10.0.0.0:2375 ʦ Status: Healthy … ʦ Labels: kernelversion=4.2.0-23-generic, operatingsystem=Ubuntu 14.04.3 LTS, … ʦ Error: (none) ʦ UpdatedAt: 2016-02-09T19:52:56Z
  12. Rescheduling • Experimental feature swarm --experimental manage … • On

    node failure docker run -e “reschedule:on-node-failure” …
  13. New events $ docker events … 2016-02-09T12:02:01 container create XXX

    (com.docker.swarm.id=YYY, image=busybox, node.addr=10.0.0.1:2375, node.name=node-1) … 2016-02-09T12:02:01 network connect ZZZ (node.name=node-1, type=bridge, container=XXX, name=bridge, node.addr=10.0.0.1:2375,) … 2016-02-09T12:03:10 swarm engine_connect (node.name=node-2, node.addr=10.0.0.2:2375) …
  14. Voting App Redis queue Java worker PG database Results app

    “vote” network “result” network 10.0.1.0/24 10.0.2.0/24