moon indicating dark mode
sun indicating light mode

Create a k0s Kubernetes Cluster with Ansible

January 03, 2021

k0s Control plane architecture

Last November, the new Kubernetes distro k0s was released by Mirantis. The distribution has already collected 3k likes on Github in this short time. k0s promises to simplify the deployment of Kubernetes clusters massively. It combines all the required K8s components into a single binary. By doing that it does not make compromises but instead has some great benefits compared to other distros. I especially like the following features:

  • It’s a simple way to use the latest vanilla K8s upstream currently available
  • It isolates the control plane by default
  • Elastic control-plane

I put together a Ansible playbook that you can use to create a k0s Cluster in automated fashion. The playbook is available at

To quickly create a Cluster with three control plane nodes and worker nodes I added a script that creates VMs using Multipass and a Python script that creates a Ansible Inventory that assigns the nodes to their jobs in your k0s lab cluster.

A guide on how to use the playbook and the scripts is available in the k0s Documentation. So if you want to quickly create a Cluster and at the same time learn about infrastructure as code just give it a spin.

I plan on keeping the playbook up to date with the current k0s version. Of course I welcome issues to and pull requests against the playbook repository!

To create a cluster just follow these steps:

# Clone the playbook
git clone
cd k0s-ansible
# Create 5 VMs with multipass
# Create your Ansible inventory
cp -rfp inventory/sample inventory/multipass
cp tools/inventory.yml inventory/multipass/inventory.yml
# Provision your k0s cluster
ansible-playbook site.yml -i inventory/multipass/inventory.yml
# Connect and test your cluster
export KUBECONFIG=~/k0s-ansible/inventory/multipass/artifacts/k0s-kubeconfig.yml
kubectl get nodes -o wide
k0s-4 Ready <none> 21s v1.20.1-k0s1 <none> Ubuntu 20.04.1 LTS 5.4.0-54-generic containerd://1.4.3
k0s-5 Ready <none> 21s v1.20.1-k0s1 <none> Ubuntu 20.04.1 LTS 5.4.0-54-generic containerd://1.4.3
# hello k0s πŸ‘‹
kubectl run hello-k0s --rm -it --restart=Never --command -- sh -c "echo hello k0s"
hello k0s

I'm starting this blog in order to share and learn new fun stuff on system adminstration and full stack web development. You can reach me via e-mail.