Using a local cluster is very handy to get started with Kubernetes, or to test things quickly. In this example, we’ll use k0s, a lightweight open-source Kubernetes distribution defined as “the simple, solid & certified Kubernetes distribution that works on any infrastructure: bare-metal, on-premises, edge, IoT, public & private clouds.”
We’ll use Multipass, which is a convenient tool to launch Ubuntu virtual machines on Mac, Linux, or Windows, and install k0s on this VMs.
We’ll only create a single node Kubernetes, as this usually enough to get started.
Pre-requisite
On your local machine, install kubectl. It’s the essential tool for communicating with a Kubernetes cluster from the command line.
Creating an Ubuntu VM
Once you’ve installed Multipass, create an Ubuntu 24.04 virtual machine named k3s with 2G of memory allocated. This process should take a few tens of seconds.
multipass launch --name k0s --memory 2G
Then get the IP address of the newly created VM.
IP=$(multipass info k0s | grep IP | awk '{print $2}')
Installing k0s
Run the following commands to install and run k0s in the VM.
multipass exec k0s -- bash -c "
curl -sSf https://get.k0s.sh | sudo sh
sudo k0s install controller --single
sudo k0s start"
curl -sfL https://get.k0s.sh | sudo sh
, used to install k0s comes from the official k0s documentation
Getting the kubeconfig file
First, generate the kubeconfig file as follows.
multipass exec k0s -- bash -c 'sudo k0s kubeconfig admin' > kubeconfig.k0s
Next, configure your local kubectl.
export KUBECONFIG=$PWD/kubeconfig.k0s
Then, list the cluster’s nodes (only one in the current setup).
kubectl get no
Also list the Pods running in the cluster.
kubectl get pods -A