I put a Raspberry Pi cluster together - now what should I do?
I have a problem when it comes to Raspberry Pis. Actually, I have a problem with impulsivity, but I'll pretend that the issue is exclusive to Raspberry Pis. The great thing is that the cost of the various Raspberry Pi models is low enough that it's relatively cheap to build a cluster.
I knew I wanted to do the following:
- Learn more about Kubernetes without using work resources.
- Try some of the very neat open source projects that are mentioned on the Kubernetes podcast (ie, OpenFaas, MinIO, etc).
- Play around with some DIY home automation. I'm not completely sure what I want to do yet, but I have a bunch of Philips Hue lights that are begging to be controlled from the cluster.
I did a search for "Raspberry Pi cluster" and "Kubernetes", and found Jeff Geerling's Raspberry Pi Cluster Ep 2 - Setting up the Cluster YouTube video.
Jeff's Kubernetes and Raspberry Pi videos are packed with useful information and he communicates very clearly. Definitely check them out!
I mostly followed his related blog post when I went to install K3s on my cluster. The K3s site has great information as well, and the install steps (all two of them) are very simple to follow.
However, I ran into an issue or two when I was first setting up the cluster, so I took some notes that I'm providing here.
Initial OS Selection and Setup
cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
On First Boot
I made the following changes on first boot of each image:
sudo PRUNE_MODULES=1 RPI_REBOOT=1 SKIP_WARNING=1 rpi-update
Before Installing K3s
sudo iptables -F sudo update-alternatives --set iptables /usr/sbin/iptables-legacy sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy sudo reboot
echo -e "10.0.1.1\twhite" | sudo tee -a /etc/hosts echo -e "10.0.1.2\tred" | sudo tee -a /etc/hosts echo -e "10.0.1.3\tgreen" | sudo tee -a /etc/hosts echo -e "10.0.1.4\tblue" | sudo tee -a /etc/hosts echo -e "10.0.1.5\tblack" | sudo tee -a /etc/hosts
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s -
export TOKEN=`ssh -t pi@white sudo cat /var/lib/rancher/k3s/server/node-token` curl -sfL https://get.k3s.io | K3S_URL=https://10.0.1.1:6443 K3S_TOKEN=$TOKEN sh -
Test the Cluster
If you haven’t already installed kubectl, then install it now.
scp pi@white:/etc/rancher/k3s/k3s.yaml ~/.kube/config
Let's Run Something!
> echo -n "Hello" | curl --data-binary @- http://red:31111 _ _ _ _ | | | | ___| | | ___ | |_| |/ _ \ | |/ _ \ | _ | __/ | | (_) | |_| |_|\___|_|_|\___/