89a8593cc6 | ||
---|---|---|
.gitignore | ||
LICENSE | ||
README.md | ||
Vagrantfile | ||
vagrant_rancheros_guest_plugin.rb |
README.md
Rancher Swarm
A simple tutorial on how to make a Docker swarm cluster on top of Vagrant.
For this you need at least 3 GB of ram free on your computer. This might work with less if you change the ram levels, but just have at least 3 GB of ram free just in case.
How to cluster
First, you need the machines to cluster:
$ vagrant up
Now, you need a docker swarm discovery token:
$ docker run --rm swarm create
fd243153d366c4fc088de73681b884ad
First you'll need to get the first runner online and waiting in the cluster.
$ vagrant ssh runner-01
runner-01$ sudo ros c set user_docker.args '[docker, -d, -s, overlay, -G, docker, -H, unix:///var/run/docker.sock, -H, tcp://0.0.0.0:2375]'
runner-01$ sudo system-docker restart docker
Now have that machine join the cluster:
runner-01$ docker run --name swarm -d swarm join --addr=172.19.8.101:2375 token://fd243153d366c4fc088de73681b884ad
Repeat this for the other two nodes.
Now connect to the management vm:
$ vagrant ssh manager
manager$ docker run -d -p 2375:2375 swarm manage token://fd243153d366c4fc088de73681b884ad
You now have a working cluster. Now to prove it:
$ docker -H tcp://172.19.8.104:2375 info
Containers: 3
Images: 3
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 3
runner-01: 172.19.8.101:2375
└ Containers: 1
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 1.025 GiB
└ Labels: executiondriver=native-0.2, kernelversion=3.19.8-ckt1-rancher, operatingsystem=<unknown>, storagedriver=overlay
runner-02: 172.19.8.102:2375
└ Containers: 1
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 1.025 GiB
└ Labels: executiondriver=native-0.2, kernelversion=3.19.8-ckt1-rancher, operatingsystem=<unknown>, storagedriver=overlay
runner-03: 172.19.8.103:2375
└ Containers: 1
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 1.025 GiB
└ Labels: executiondriver=native-0.2, kernelversion=3.19.8-ckt1-rancher, operatingsystem=<unknown>, storagedriver=overlay
CPUs: 3
Total Memory: 3.075 GiB
Name: 66d026cc952c
You may need to unset DOCKER_TLS_VERIFY
depending on your configuration.
Now you have a working docker swarm!