Setting up a private Kubernetes cluster with k0sctl

2023/05/28

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: k0sctlarrow-up-right. This is an automation to run k0sarrow-up-right 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.

Prerequisites

First, setup the machines that will become nodes in the Kubernetes cluster as Ubuntu serversarrow-up-right. See this previous guide:

Ubuntu GPU Server Setupchevron-right

Check the node requirements by k0sctlarrow-up-right, e.g. the host account must be root or have passwordless root access. To do the latter on the node:

  1. SSH into the node

  2. open sudoers file: sudo nano /etc/sudoers

  3. below the line includedir /etc/sudoers.d, add: <username> ALL=(ALL) NOPASSWD: ALL (replace <username>)

Installation

Install k0sctlarrow-up-right and kubectlarrow-up-right on your laptop (e.g. MacOS) with SSH access to the nodes:

brew install k0sproject/tap/k0sctl
brew install kubectl

Create Kubernetes cluster

Then, follow the k0sctl guidearrow-up-right:

  1. Create initial config file.

  1. Configure nodes in the hosts fields, e.g. choose the appropriate rolesarrow-up-right. Additionally:

    1. Default setup with kuberouter has issues, use Calico instead

    2. Add the builtin openEBSarrow-up-right for persistent storage (PVC)

    3. Add other Helm charts: cert-manager, Prometheus stack, Grafana

  1. Once cluster is set up, get the kubeconfig for kubectl to access the cluster.

That's all! See the k0sctl docarrow-up-right for more operations, e.g. add nodes, upgrade, reset.

Last updated