Kubernetes in your homelab

A short post about setting up Kubernetes for advanced training at Homelab.

Kubernetes in your homelab

I like to deal with new technologies. Admittedly, Kubernetes is not really new, but until now I simply lacked the points of contact with it. I want to change that now, because I think there is a lot of movement in this topic. All relevant cloud providers now have Kubernetes in their portfolio, VMware is moving in the same direction with Tanzu, IBM and RedHat with OpenShift as well.

Of course, you can also simply create an account with a credit card at one of the providers, set up a Kubernetes cluster there and see how the money on the card becomes less. I usually don't have the time to follow something like this all the time, so it's more convenient for me if the stuff is just sitting in my LAN at home and I can just use it when I need it.

Of course there are also possibilities to start the "just quickly" in a VM on your own workstation e.g. with minikube (https://minikube.sigs.k8s.io/docs/) or kind (https://kind.sigs.k8s.io/). Personally, however, too much runs automatically, which is great in principle, but if I want to understand connections, it helps me if I have to touch something now and then.

Some time ago Rancher created a Kubernetes variant with a reduced volume. k3s (https://k3s.io/). Inspired by the blog post of Alex Ellis (https://blog.alexellis.io/test-drive-k3s-on-raspberry-pi/) and his OpenFaaS project it was clear, it will be a cluster of Raspberries.

So briefly read in and compiled a hardware list:

amount description purpose
4 Raspberry Pi4 4GB Master and Worker Nodes
4 Power Supply USB-C power
4 SD-Card 32GB raspbian OS
1 USB SSD 500GB NFS Storage
1 Geekpi Cluster Case Case, Cooler + Fan

The above setup is not highly available, because the NFS share is only attached to the masternode and is exported to the workers and mounted there. There is the possibility to create distributed storage with Longhorn, Ceph or similar tools, but the first user reports did not convince me. It doesn't help if the majority of the cluster resources are used for the storage processes. That's why I deliberately chose a variant with a master and attached storage in the form of a USB SSD (which was also outrageously cheap).

The setup is quite simple, the current Raspian OS Lite image is copied to the SD cards and an empty file "ssh" is created in the root directory of the SD card. After that the card is plugged into a Pi, connected to the network and turned on. If DHCP is available in the LAN, you can login directly to the freshly started Pi with ssh and make the remaining settings.

Basically I followed the good quick start guide (https://github.com/alexellis/k3sup#-micro-tutorial-for-raspberry-pi-2-3-or-4-). With this, at least the Kubernetes cluster was up relatively quickly.

export KUBECONFIG=`pwd`/kubeconfig
kubectl get node
phm-w3   Ready    <none>   16h   v1.19.8+k3s1
phm      Ready    master   16h   v1.19.8+k3s1
phm-w2   Ready    <none>   15h   v1.19.8+k3s1
phm-w1   Ready    <none>   16h   v1.19.8+k3s1

With Arcade (https://github.com/alexellis/arkade), a Kubernetes dashboard or other tools that may be needed are quickly deployed.


I still have quite a few components and tools on the cloud native computing foundation list, which I will take a closer look at in this context. The variety overwhelms you at the beginning. If you want to get started yourself, you can find a free eBook at Microsoft (https://azure.microsoft.com/en-us/resources/kubernetes-ebook-collection/). Whether it says Azure on it or not is almost irrelevant for Kubernetes; in principle, the providers are all cooking with the same water.