DIY docker cluster with raspberry pi

overview

Shopping list

4x Raspberry Pi 3 (Kjell & Company)
4x SD cards (8 GB or more)
4x LAN cables (25 cm)
4x Micro-USB cables (25 cm)
3x Multi-Pi stackable Raspberry Pi case
1x Power supply (Clas Ohlson)
1x 5-port switch

Storage

The raspberry pi images are usually less than 1 GB so installing your OS will not take up that much space at all. However it is always nice to have plenty of room for logs and content. We chose to buy a 16 GB card for each Pi, my recommendation is that you should get at least 8 GB.

Power supply

When it comes to the power supply, the recommended current for a single Raspberry Pi 3 is 2.5 A. We went for a five-port USB charger that outputs up to 2.1 A per port and a total of 8 A. It proved to be sufficient for powering all four Pi's as well as our network switch.

This charger also fits neatly into the stackable case.

Switch

Try to find an as small switch as you can. There are a number of models that can fit into the stackable case, which is what we are going for.

Setup

Hardware

Start by unpacking the shelves for the stackable cases, then unpack one Pi at a time and mount each on on a shelf. Be careful not to let any metal parts touch the metal parts on the curcuit board and try holding the Pi around the edges when handling it.

Also fasten your network switch and your USB charger on one shelf each. We used double-sided tape for this (and additional electrical tape for added stability).

When fastening the switch and the power supply, think about how you will be able to access the ports and which direction they should be facing. You want to be able to plug and unplug the LAN cables easily.

After you are done mounting each unit on its shelf, begin assembling the stack. We chose to have the charger at the bottom, followed by the switch, followed by the Pi's. Having the weight of the charger at the bottom makes the stack stand steady.

Software

There are a bunch of different images you can simply download and flash onto your SD card.

Hypriot is my favorite image right now. It comes loaded with a fresh release of docker and is very easy to install with their own flash utility.

With hypriot, you basically setup a swarm cluster by flashing your SD cards, inserting them into your Pi's and then running docker swarm init on one of them and docker swarm join on the others.

work in progress

comments powered by Disqus