Setting up a private Kubernetes cluster with k0sctl
2023/05/28
Last updated
2023/05/28
Last updated
In my continuing quest for the easiest, fastest way to set up a private Kubernetes cluster (e.g. on home lab server), a solution finally exists: k0sctl. This is an automation to run k0s on nodes that you have SSH access to, e.g. your laptop.
As an optional brief background info, see the previous private Kubernetes setup guide with plain k0s.
First, setup the machines that will become nodes in the Kubernetes cluster as Ubuntu servers. See this previous guide:
Check the node requirements by k0sctl, e.g. the host account must be root
or have passwordless root access. To do the latter on the node:
SSH into the node
open sudoers file: sudo nano /etc/sudoers
below the line includedir /etc/sudoers.d
, add: <username> ALL=(ALL) NOPASSWD: ALL
(replace <username>)
Install k0sctl and kubectl on your laptop (e.g. MacOS) with SSH access to the nodes:
Then, follow the k0sctl guide:
Create initial config file.
Configure nodes in the hosts
fields, e.g. choose the appropriate roles. Additionally:
Default setup with kuberouter has issues, use Calico instead
Add the builtin openEBS for persistent storage (PVC)
Add other Helm charts: cert-manager, Prometheus stack, Grafana
Apply to deploy the cluster.
Once cluster is set up, get the kubeconfig for kubectl to access the cluster.
That's all! See the k0sctl doc for more operations, e.g. add nodes, upgrade, reset.