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 github.com/movd/k0s-ansible.

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 https://github.com/movd/k0s-ansible
cd k0s-ansible

# Create 5 VMs with multipass
./tools/multipass_create_instances.sh

# Create your Ansible inventory
cp -rfp inventory/sample inventory/multipass
./tools/multipass_generate_inventory.py
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
NAME    STATUS     ROLES    AGE   VERSION        INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
k0s-4   Ready      <none>   21s   v1.20.1-k0s1   192.168.64.57   <none>        Ubuntu 20.04.1 LTS   5.4.0-54-generic   containerd://1.4.3
k0s-5   Ready      <none>   21s   v1.20.1-k0s1   192.168.64.58   <none>        Ubuntu 20.04.1 LTS   5.4.0-54-generic   containerd://1.4.3

# hello k0s 👋
kubectl run hello-k0s --image=quay.io/prometheus/busybox --rm -it --restart=Never --command -- sh -c "echo hello k0s"
hello k0s