Rancher-Swarm/README.md

82 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2015-08-21 20:09:35 +00:00
Rancher Swarm
=============
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
A simple tutorial on how to make a Docker swarm cluster on top of Vagrant.
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
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.
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
How to cluster
--------------
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
First, you need the machines to cluster:
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
```console
$ vagrant up
2015-02-24 23:04:22 +00:00
```
2015-08-21 20:09:35 +00:00
Now, you need a docker swarm discovery token:
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
```console
$ docker run --rm swarm create
fd243153d366c4fc088de73681b884ad
2015-02-24 23:04:22 +00:00
```
2015-03-07 08:12:15 +00:00
2015-08-21 20:09:35 +00:00
First you'll need to get the first runner online and waiting in the cluster.
2015-03-07 08:12:15 +00:00
2015-08-21 20:09:35 +00:00
```console
$ 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
2015-03-07 08:12:15 +00:00
```
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
Now have that machine join the cluster:
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
```console
runner-01$ docker run --name swarm -d swarm join --addr=172.19.8.101:2375 token://fd243153d366c4fc088de73681b884ad
```
2015-08-21 20:09:35 +00:00
Repeat this for the other two nodes.
2015-08-21 20:09:35 +00:00
Now connect to the management vm:
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
```console
$ vagrant ssh manager
manager$ docker run -d -p 2375:2375 swarm manage token://fd243153d366c4fc088de73681b884ad
```
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
You now have a working cluster. Now to prove it:
```console
$ 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
```
2015-02-25 22:34:36 +00:00
2015-08-21 20:09:35 +00:00
You may need to unset `DOCKER_TLS_VERIFY` depending on your configuration.
2015-02-24 23:04:22 +00:00
2015-08-21 20:09:35 +00:00
Now you have a working docker swarm!