Child pages
  • POC of A Docker Swarm Cluster with Consul
Skip to end of metadata
Go to start of metadata
  1. Architectural diagram of the Docker Swarm Cluster with Consul
  2. Set up a Consul server as a container on 170.140.52.33

    docker run -d -h docker-web1 --name docker-web1 \

    -p 8300:8300 \

    -p 8301:8301 \

    -p 8301:8301/udp \

    -p 8302:8302 \

    -p 8302:8302/udp \

    -p 8400:8400 \

    -p 8500:8500 \

    -p 172.17.0.1:53:53/udp \

    progrium/consul -server -advertise 170.140.52.33 -bootstrap-expect 3


  3. Set up a Consul agent as a container on 170.140.52.34

    docker run -d -h docker-web2 --name docker-web2 \

        -p 8300:8300 \

        -p 8301:8301 \

        -p 8301:8301/udp \

        -p 8302:8302 \

        -p 8302:8302/udp \

        -p 8400:8400 \

        -p 8500:8500 \

        -p 172.17.0.1:53:53/udp \

        progrium/consul -server -advertise 170.140.52.34 -join 170.140.52.33

  4. Set up a Registrator as a container 

    docker pull gliderlabs/registrator:latest

    docker run -d --name=registrator --net=host --volume=/var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator:latest consul://localhost:8500

  5. Set up a Docker Swarm manager (master) as a container on 170.140.52.33

    docker -H tcp://170.140.52.33:2375 run -d --name swarm-manager -p 1762:2375 swarm manage consul://170.140.52.33:8500/swarm

  6. Set up a Docker Swarm agent  as a container on 170.140.52.34

    docker -H tcp://170.140.52.34:2375 run -d --name=swarm-agent-1 swarm join --addr=170.140.52.34:2375 consul://170.140.52.33:8500/swarm

  7. Test the Docker Swarm cluster

          

Test communications between the consul server and its agents:

 

 Browse http://docker-web1:8500/ui/#/dc1/nodes/docker-web1

 Expected: the Consul server and two Consul agents should be shown up

 Check on more features through the web console

 

Start the Swarm Manger on docker-web1

 $ docker start swarm-manager

 $ docker ps

 

Start the Swarm Manger on docker-web2

 $ docker start swarm-agent-1

 $ docker ps

 

Start the Swarm Manger on docker-web3

 $ docker start swarm-agent-2

 $ docker ps

 

Test communications between the swarm manager and swarm agents

 on docker-web1

 docker -H tcp://170.140.52.33:1762 info 

  It will show all agents registered with the Swarm manager 

  1. Strategy: spread

 2. Filters: health, port, dependency, affinity, constraint

 docker -H tcp://170.140.52.33:1762 ps  It will show all containers running in the cluster

 $   docker -H tcp://170.140.52.33:1762 run -d --name nginx80 -p 80:80 nginx 

  Start a container nginx80 through the Swarm manager. 

  Expected: the newly started container nginx80 should be distributed on docker-web2 or docker-web3 based on the Strategy: spread

  Observed: docker -H tcp://170.140.52.33:1762 ps

  Browse http://docker-web3.cc.emory.edu/ or http://docker-web2.cc.emory.edu/ based on the return 

 $   docker -H tcp://170.140.52.33:1762 run -d --name nginx81 -p 81:80 nginx

  Start a container nginx81 through the Swarm manager.

  Expected: the newly started container nginx81 should be distributed on docker-web2 or docker-web3.

           If the nginx80 is distributed on docker-web3, nginx81 should be distributed on docker-web2  based on the Strategy: spread

  Observed: docker -H tcp://170.140.52.33:1762 ps

  Browse http://docker-web3.cc.emory.edu:81/ or http://docker-web2.cc.emory.edu:81/ based on the return

 

 on docker-web3

 $ docker stop nginx80 

 on docker-web1

 docker -H tcp://170.140.52.33:1762 ps

  Expected: nginx80 is gone 

 on docker-web3

 $  docker stop swarm-agent-2

 docker -H tcp://170.140.52.33:1762 info

 

 

  • No labels