Instructions to build a Raspberry Pi powered Docker Swarm mini cluster in a box.
Well, first you need to buy the hardware. Here is the list of what I bought.
- Raspberry Pi 3 Model B+ (https://www.modmypi.com/raspberry-pi/set-up-kits/rpi3-model-b-plus-kits/raspberry-pi-3-model-b-plus-and-16gb-microsd-bundle)
- Cluster HAT Kit Inc. 4 x Raspberry Pi Zero (https://www.modmypi.com/raspberry-pi/iousbanalogue-expansion-1028/interfacing-1080/cluster-hat-kit-inc.-4-x-raspberry-pi-zero)
- Cluster HAT Case (https://www.modmypi.com/raspberry-pi/cases-183/raspberry-pi-b-plus2-and-3-cases-1122/cases-for-hats-and-boards-1133/cluster-hat-case)
This is the fun part. Basically unpack everything and put all the parts together.
Have a look into the assembly/
directory for more images.
This section is about setting up all five Raspberry Pi nodes with the required software. First up, make sure that you download the Raspbian images from the ClusterHAT website: https://clusterhat.com/setup-software
Since we want the Zero nodes to be able to access the internet, make sure you download the NAT Desktop controller image! Write all the images to a SD card using balenaEtcher or a similar software. Also make sure to insert the appropriate SD card into the right Raspi Zero slot.
Once switched on, perform the following steps after the first boot
- following the basic setup instructions (locale, network and wireless LAN, password, update)
- after the next reboot, open the Raspi configuration in a shell using
sudo rasp-config
- make sure you extend the partition to the full size of your SD card!
- enable SSH
Before you continue with the following steps, make sure you have performed the basic setup of all four Zero nodes. In a terminal, issue the following commands:
clusterhat on
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa pi@172.19.181.1
ssh-copy-id -i ~/.ssh/id_rsa pi@172.19.181.2
ssh-copy-id -i ~/.ssh/id_rsa pi@172.19.181.3
ssh-copy-id -i ~/.ssh/id_rsa pi@172.19.181.4
To make working with the nodes a little easier, edit your /etc/hosts
file and add the following:
172.19.181.254 master cnat
172.19.181.1 p1
172.19.181.2 p2
172.19.181.3 p3
172.19.181.4 p4