Raspberry Pi Swarm
My first project utilising the Docker containerisation platform - building a Raspberry Pi swarm and trying to work out what to do with it.
A couple of weeks ago, a friend of mine reminded me about Docker. Docker is a containerisation platform which allows you to deploy different systems very quickly and efficiently on the same host machine. Not only that, you can put several Docker hosts together in order to create a swarm. It’s like VMs, but cooler.
Having followed a fantastic tutorial by the Docker Captain, Alex Ellis, I had Docker running on one of my Pies in under an hour. I thought this was pretty cool, but I soon got bored of firing up containers which ran little Node.js apps for me. I started to wonder what it would be like if I could build a Docker swarm out of them. Having had a little look on Alex’s site, I spotted another guide for how to make a swarm of Pies. Well, I just had to try it out. I ordered some supplies in the form of SD cards from Amazon (how do they disappear like they do?!) and two Multi-Pi stackable cases from ModMyPi.
I waited on tenterhooks for a couple of days.
Once everything had arrived, I jumped straight into the assembly. I now had a 5-strong Raspberry Pi super computer sitting in front of me, nicely stacked up in the casing.
The next step was to download the Raspbian image and flash 5 SD cards. No need to go into that here, there are plenty of good guides about. Once I had them all hooked up to a switch and powered up, I installed Docker on each one of them.
Now that Docker was installed, I needed to get all the nodes to join the swarm.
To do this, I borrowed Alex’s script which he shows in his video above and modified it to include my own Pi IP addresses and issued the join command. Hey presto! I now had a Docker swarm with 5 nodes in it. That’s a total of 5 cores and 2.5 GB RAM.
Ha. That was kinda neat. The next day, my friend Ben was coming to stay and if our previous exploits were anything to go by, we were about to have a lot of fun…
My ideas for the future include:
- Alexa (favourite Christmas present) flash briefing report on my apps & services
- Development/staging servers using containers with unit testing etc
- Testing scalability of my apps & services across a distributed system with load balancing
Something I’ve seen a lot of is an Alexa Skills app deployed on AWS Lambda. For those who don’t know, Lambda is an Amazon Web Service for “serverless functions”. Alex Ellis has a great overview of what that means here. My problem with Lambda is that it feels (to me at least) that everything is a little out of control. I like to know exactly how everything works because it allows me to improve it. For example, I run my Nginx web server as a reverse proxy for a few Node.js apps and because I control everything from the DNS records down to the database connections, I can optimise it to best suit my needs. With Lambda, you’re handing your code off to Amazon to run. While this may be perfect for some people, I personally don’t like it. Due to this, I am likely going to end up writing my own Node app to communicate with Alexa which will hopefully be more fun!