diff --git a/content/posts/building-a-docker-swarm-with-pis.md b/content/posts/building-a-docker-swarm-with-pis.md index f0c2102..72cb47b 100644 --- a/content/posts/building-a-docker-swarm-with-pis.md +++ b/content/posts/building-a-docker-swarm-with-pis.md @@ -18,7 +18,7 @@ showtoc: true searchHidden: false --- -## **Introduction** +## **Intro** The _Raspberry Pi_ from it's first iteration has been a great hit. Adopted by many as the computer of choice for projects, and for very good reason. The Pi is a fully fledged computer that fits in @@ -47,12 +47,12 @@ than a Pi cluster. ![Insert Image of cluster here]() -### **Goal of this post** +### **Point of this post** Hopefully after following this post you will have setup _Docker swarm_ on a cluster of Pis **- stay even if you currently only have one -** and understand how to bend it to your will 🦾. -### **Why** ***Docker Swarm*** +### **Why** ***Docker Swarm*** 🧐 While we can manage each docker node - _Raspberry Pi_ - individually , **_Docker swarm_ enables us to manage all the devices from a single main node** making managing the cluster a lot easier. @@ -105,29 +105,68 @@ have 4 8GB nodes then you have a combined total of: * Use smaller SD Cards try not to go below 32GB (Reccomended 64GB If money saved elsewhere) ## **BUILD TIME !!** +Pull yourself up by your bootstraps were jumping into this one +runnig 💨 + ### **Image the SD Cards** So interesting fact the CPUs used in the raspberry pi 4 use an ARM64 -archetecture meaning they're 64bit. When looking for images of -Raspbian you will only find 32bit variants which will work however -will not make use of all the hardware which is just a waste. 64bit -images exist however are well hidden, Dont fear 😨 **you can download -the latest images from the [raspberrypi.org index](https://downloads.raspberrypi.org/raspios_arm64/images/)** +archetecture. When looking for images of Raspbian you will only find +32bit variants which will work however will not make use of all the +hardware which is just a waste. 64bit images exist however are well +hidden, Dont fear 😨 **you can download the latest images from the +[raspberrypi.org index](https://downloads.raspberrypi.org/raspios_arm64/images/)** -To write the cards I use the Raspberry Pi imager [available here](https://www.raspberrypi.com/software/). -once that is installed and you have the 64bit raspbian image -downloaded do the following: -1. Click CHOOSE OS - 1. Click Use custom - 2. Select the 64bit rasbian image and open -2. Click CHOOSE STORAGE - 1. Select storage device -3. Click WRITE +To write the cards I use the [**Raspberry Pi imager**](https://www.raspberrypi.com/software/). +once you have **rpi-imager** installed and you have the 64bit raspbian +image, open ```sudo rpi-imager``` and on the "CHOOSE OS" section go to +the bottom and select use custom image. -We dont need to unzip the file as the tool is clever enough to +> We dont need to unzip the file as the tool is clever enough to handle that for us -**repeat steps for number of cards you have** +**Before removing the SD card, mount the boot partition - usually the +first partition, look for a file called cmdline.txt - and create an +empty file called ssh** ```sudo touch ssh``` this basically enables +SSH on the Pis first boot allowing us to access the Pis in a totally +headless manner. ### Assemble the cluster +So assembly is very dependant on the kit you bought, and more +often than not the stuff needed here comes with instructions or is +self explanitory. So go ahead and assemble the cluster 🛠 + +**There is an order of operations that I reccomend:** +* Install PoE hats onto the Pis +* Install the SD Cards into the Pis +* Assemble the case and install Pis +* plug in ethernet cables + +**Now allow the Pis to boot for a few minutes so it can resize the +file system** + +### **Sort out the Network bits** +This is the easy part, there are two methods we can use to set a +static IP address, one is on your DHCP server and the other is on +the device itself. Personally I prefer to set static IPs on the +device itself so I will cover that here. + +To find the current ip of your Pis you can go to your DHCP server +and look for the DHCP leases for the Pis. + +**SSH to the Pi** then open and edit the following files +* /etc/hosts + * edit this line with your hostname: ```127.0.1.1 mainpi``` +* /etc/hostname + * edit this file with your hostname: ```mainpi``` +* /etc/dhcpcd.conf + * knowing we will be using only static IPs here I delete + everything in the file add the following + * ``` + interface eth0 + static ip_address=10.10.10.20/24 + static routers=10.10.10.1 + static domain_name_servers=10.10.10.1 + ``` +**Now reboot the pi** ```sudo shutdown -r now```