Setting Up and Operating Home Kubernetes
For my home Kubernetes setup, I used to manage it with kubeadm, but a few years ago I rebuilt it using K3s, which is much easier to install.
K3s is a CNCF project, and you can set up Kubernetes with just this single command:
curl -sfL https://get.k3s.io | sh -
My home Kubernetes is a 3-node setup (1 control plane node, 2 worker nodes). I install k3s on each, use the node token generated on the control plane node, and just start the workers to build the Kubernetes cluster.
I’ve put this all in an ansible playbook to operate my home Kubernetes.
Upgrading Kubernetes with system-upgrade-controller
A challenge that inevitably arises when operating Kubernetes is that version upgrades are a pain. This is because Kubernetes is still an evolving piece of software with daily updates for vulnerability fixes and feature additions.
So I introduced rancher/system-upgrade-controller to be able to maintain the stable version of Kubernetes automatically.
As you’ll see by following Automated Upgrades | K3s, the procedure is:
- Install system-upgrade-controller into Kubernetes
- Define a
upgrade.cattle.io/v1Plan resource to upgrade the Kubernetes version
One thing to note: step 1 can be installed with:
kubectl apply -f https://github.com/rancher/system-upgrade-controller/releases/latest/download/system-upgrade-controller.yaml
But before applying the Plan resource, you need to apply the CRD first:
kubectl apply -f https://github.com/rancher/system-upgrade-controller/releases/latest/download/crd.yaml
Also, as noted in the repository, system-upgrade-controller requires strong permissions. If your Kubernetes is accessible from the internet, make sure to operate it with thorough security measures.
The PR Where I Actually Introduced This
The above work was simply applied with ansible, but I’ll include the PR for reference: