Build A Raspberry Pi Cluster for Easy Access

(Edited)

Im gonna post the installation process here so that it will be easy for me as well as who want to build a cluster for easy access
Raspberry Pi cluster using kuberenetes (rancher k3s)

Flash Raspbian OS Lite (64 Bit) onto an SD Card
Once flashed disconnect and connect back the SD Card and now u should see bootfs on ur drive list, open that
open the config.txt in bootfs drive, in the last line under [all] paste the below lines

over_voltage_delta=50000
arm_freq=2900

(The above step is if you want your raspberry pi to be over clocked, if it throws some kernel errors try increasing over_voltage_delta to 100000 or reducing the arm_freq)

Next step open up the cmdline.txt from the same bootfs drive, and at the end of the whole line/sentence in there just give a space and paste the below lines

cgroup_memory=1 cgroup_enable=memory ip=YOUR_STATIC_IP::YOUR_GATEWAY:YOUR_SUBNET_MASK:HOST_NAME:INTERFACE:off

(now here, YOUR_STATIC_IP must be edited to an IP thats not used in ur applications and is available in ur subnet mask, the YOUR_GATEWAY will be the default gateway of ur router its mostly 192.168.1.1, YOUR_SUBNET_MASK will either be 255.255.255.0 for most of u again check it and it may vary, INTERFACE is the interface through which ur raspberry pi gets internet from, if u are using WiFi use wlan0 or ethernet eth0)

Create a blank file called ssh to enable ssh to ur rpi
now put that SD card into ur rpi and boot it up, if it asks for initial configuration like username and password (for me it does) then enter it and let it reboot, do its thing, once u are done with that then u will be able to ssh into the pi
We need the legacy iptables so set those up using the following commands below

sudo apt install iptables -y
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy

after u do that u should see
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode in the terminal

then do a reboot sudo reboot
once its back up ssh into it again and take root permissions sudo su -
For setting up the master curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s -
Get the token from the master cat /var/lib/rancher/k3s/server/node-token
For setting up the slaves curl -sfL https://get.k3s.io | K3S_TOKEN="YOUR MASTER TOKEN" K3S_URL="https://[YOUR MASTER IP ADDRESS]:6443" K3S_NODE_NAME="SLAVE NAME" sh -

now here the YOUR MASTER TOKEN should be the token we printed out from the master, [YOUR MASTER IP ADDRESS] should be the ssh ip address of ur pi (local ip or the ip u set up earlier in the cmdline.txt file) and the SLAVE NAME should be the name of ur slave pi, make sure to name it differently for different rpis if u are using multiple of them.

if u do kubectl get nodes on ur master u should be able to see the slave pis and the master ready to work

root@raspberrypi:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
raspberrypi Ready control-plane,master 106m v1.29.5+k3s1
rpislave1 Ready 82m v1.29.5+k3s1
rpislave2 Ready 65m v1.29.5+k3s1



0
0
0.000

2 comments