The goal is to create a Docker swarm cluster with 3 nodes for under 200 euro’s, but it still has to be capable to run a nginx proxy, couple of static websites, management UI for Docker, home automation and pi-hole. Because the limit is set to 200 euro’s the choice of system was very easy: Raspberry Pi 3 B+. The Raspberry Pi costs around 40 euro’s in the Netherlands so the first 120 euro’s is already gone. The other 80 euro’s we will use for powersupply, sd cards. And I will cheat a bit because I had an unused 5ports ethernet switch laying in a darkcorner.
- 3x Raspberry Pi 3 B+ - 3x 2.5A micro-usb powersupply - 3x 8GB micro sdhc cards - 1x 5 ports 10/100/1000Mbit switch - 4x 0.5mtr CAT6 UTP patch capable
To run Docker swarm on a Raspberry Pi we need to have an operating system flashed on the sdhc cards. HypriotOS is a small raspbian jessie image with docker (17.10.0-ce) pre-installed. Another advantage of HypriotOS is that you can do a headless installation. HypriotOS can use cloud-init to preseed some basic configurations like hostname, username, password, installed extra packages and even the settings for your WiFI is you like to use it. This is all done by editing
+-----------+ | manager01 | ---------- +-----------+ \ \ +----------+ +--------+ +----------+ | worker01 | --------- | switch | --------- | internet | +----------+ +--------+ +----------+ / +----------+ / | worker02 | ---------- +----------+ Network: manager01 -> manager01.cluster.haraldvdl.nl -> 192.168.99.100 worker01 -> worker01.cluster.haraldvdl.nl -> 192.168.99.101 worker02 -> worker02.cluster.haraldvdl.nl -> 192.168.99.102
Configuration of the manager
Docker swarm first node is by default the manager node. For Docker swarm a minimum of one manager is required. The manager node is also capable of running Docker service. On the other hand, a worker node can’t do manager tasks. You have to promote the worker to a manager node.
Configurattion of the worker
The worker nodes are the best scalable of this type of cluster. Buy a Pi, flash sdhc card, boot Pi and run a command. And your new extra worker node is online.
Optional Docker Services
The following steps are not needed, but will give some advantage over the manual way of running docker command for creating stacks an services that will run in docker swarm.
Portainer is a docker management UI for managing docker hosts and/or docker swarm clusters. To deploy this services you need to run a single command on the manager node in your docker swarm cluster.