Kubernetes on NixOS
This document will serve to document the way I setup my own little personal kubernetes cluster on NixOS. I am using virtual machines for this (as of today) because it is simpler to use, and as for microk8s document, I rely on the fact that my network setup is capable of assigning a predefined IP to a given mac address.
Why Kubernetes at home ?
The first question that can come to mind is “why the hell do you want to setup a kubernetes cluster at home” ? And… that’s a valid question.
I work daily on Kubernetes and OpenShift, and on a CI/CD tooling that I want to be as useful as possible. If I don’t use it myself, what the hell am I doing right ? That’s the main reason why setuping a Kubernetes (and of course Tekton on it) — gaining operational knowledge, find the gap and enhancements, …
Bootstrap the cluster
How big should the cluster be ? 3 nodes or 5 nodes ? Let’s start with 3, and figure the rest out.
We need to do the following to boostrap the cluster:
- Configure the network to allocate a set of IP for a set a MAC address
- Create VMs images (
qcow2
) with NixOS and the base system on - Create VMs on a remote server libvirt
- Hopefully enjoy, and
ssh
onto them in need be
Ideally, the image we build is using the configuration, this means we should, in theory,
use nixos-generate
targeting our node configuration, and it should be the exact same thing
used for morph
.
Once the images are created, we need to copy them to the right host and from there, create the virtual machine. Ideally, we do this automatically, command-line, …