Portable #RaspberryPI #Docker #Swarm – Static IP, Ethernet based, #Portainer

By | August 29, 2017

As I discussed in post Portable #Docker #Swarm made of #RaspberryPI – Updated hardware there were several hardware updates done to the swarm. One of the updates was adding a switch and connecting all the Raspberry PIs to the switch.
First version of the Docker Swarm was done using the wifi connections of the PIs. This is not so reliable as the IPs were obtained through DHCP (so they may change) and the wifi to which they are linked is my house Wifi so not so mobile.
In the following I will change the swarm to a static IP, ethernet based swarm

STEP 1: Set static IPs for eth0 interface of the swarm nodes

To set up a static IP for an interface in Raspbian Jessie one has to add at the end of /etc/dhcpcd.conf the following:

Where:
line 1: declares to what interface we want to do the changes
line 2: declares the static ip (note that this is different for each node but same mask /24)
line 3: declares the address of the default route, the IP of the Edimax router to which Raspberry PIs are connected through the switch.

STEP 2: Recreate the Docker Swarm
On one of the former swarm master nodes do:

This will force leave the former swarm and then initialize a new swarm, but this time using the eth0 IP address.

Then we can obtain the worker and manager tokens as:

STEP 3: Add all the other swarm nodes
This last step is easy done by executing the commands obtained at Step 2 on the designated worker(2) and manager(3) nodes.

STEP 4: Deploy portainer for monitoring
To monitor the new swarm deploy on the swarm a portainer (https://github.com/portainer) instance by executing on PI1 (master node) the following:

Now I can monitor the swarm directly from PI5 screen.

Look at that 20 CPUs !!! a monster 🙂

Advertisements

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.