Building a k8s lab part01

Ok, so I'm finally getting around to building a Kubernetes lab locally. This is a real one, not a bunch of VMs on a few random machines, but purpose built Raspberry Pi boxes to do this.

There are a number of ways to do this, and I might do this more than once, but for the first time I'm going to follow the instructions in the OReilly book Kubernetes Up and Running. Hypriot I did consider using the Ubuntu instructions with MicroK8s, but I've done that at small scale before.

I download the latest version, and have to dig a bit for the instructions. The dled file is compressed, and when I find the instructions I uncompress and use Rufus to write it to an SD card. I needed to do a bit more searching, because its not an ISO but an IMG file. I then eject it and insert it into the Pi, and boot it.

We boot, and get the rainbow screen. Then we get a flash and I have to reset my monitor to follow the Pi output. Hrm, seems stuck at the rainbow screen. Maybe it's a power thing? Wait, now I see the activity light flicker; maybe it's just because I need a Kayboard? Let's try that. No joy; although the keyboard lights up, and hitting CTRL-ALT-DEL seems to reboot, nothing, just rainbow screen. Ugh. I try to unplug the USB-C power and plug it back in; rainbow, activity light flickers, and then nothing. Double Ugh. Might need to do a bit more reading, and maybe try another image.

I did a couple of other things then finally tried with Raspian which it turns out is now named Raspberry Pi OS, and things worked. This will add steps for me though, as Hypriot had a bunch of stuff pre-installed. On other hand, as I did some troubleshooting, I figured out Hypriot hasn't had a release since 2020, although I do see activity on some of the Repos from last year, so I don't know if it's in hibernation or has been abandoned.

So, boot RaspPiOS and let's install docker. We start by doing ... uh, wait. Ooops, I don't have a network, so plug in to my ethernet and ... there we go, DHCP works, yay. Okay, as I was saying, Install docker by "apt-get install docker". Takes a few seconds, and we are ready for the next step.

Next, we have to enable things so we can install Kubernetes, and that starts with it's GPG key and setting the repo. First I had to snag the key, then add it, and finally create a file with the repo listed. To get things cooking, I had to do an update/upgrade. Then we are ready to install Kubernetes itself.

The magic incantation is "apt-get install -y kubelet kubeadm kubectl kubernets-cni", and then to wait. It'll take a bit to spin through, and while we're installing a bunch of top level packages, a number of dependencies will get pulled in as well.

Finally, we're ready to start the cluster. To do this, we invoke "kubeadm init --pod-network-cidr 10.244.0.0/16 --apiserver-advertise-address 10.0.0.1 --apiserver-cert-extra-sans kubernetes.cluster.home". And of course that fails.

Well, not in the most obvious way. It fails because of "desc = unknown service", and so I do some googling and I find this question, so I change the config file and re-run, and get a different error. This time, it's "missing cgroups: memory", so I google again and find this question eventually -- my first hit said to update /etc/default/grub and reboot, which did nothing -- but this thread pointed me at the correct (for RaspPi) /boot/cmdline.txt change. It meant I had to add "cgroup_enable=memory cgroup_memory=1" to the end of that line, and bang things started to rumble to life, only to die a bit further down.

But, most important, it isn't dying in the preflight checks, so I believe this is now in the actual Kubernetes startup, which I think I need an actual network to pull down outside images. I also need to do an alias to spin up the local net it needs for Kubernetes. Fun fun.

So, I'm not running pods yet, but pretty close.

=== Update: Adding a temp network helped, but it timed out on the kubelet check. So, we are quite close. Going to do some hacking to figure out what is up here.

links

social