FIELD NOTESKUBERNETES

k0s or MicroK8s: who changes the cluster after you install it

MicroK8s patches itself from the Snap Store and installs Canonical's choice of ingress when you enable an addon; k0s does only what you declared. Which suits a Pi lab, an edge fleet and a single production box.

By Captain Spitt McGee5 min readPublished
ON THIS PAGE
MicroK8s and k0s side by side. On MicroK8s, the Snap Store refreshes the node through snapd on a schedule, the ingress addon runs Traefik and also serves the nginx class, and dqlite becomes HA on its own at three nodes. On k0s, a controller with no kubelet and a worker change only when you run k0sctl apply or install a new binary, and k0s.yaml declares the ingress and storage. Drawn in archhy.

k0s and MicroK8s both put upstream Kubernetes on a machine that stays, and they give opposite answers to the question that matters once it is running: who changes the cluster after you install it. MicroK8s is a Canonical snap that patches itself from the Snap Store on a schedule and installs Canonical's choice of ingress, storage and load balancer when you enable an addon. k0s is a single binary that does only what you declared: no ingress, no load balancer, no storage class, controllers that run no workloads, and no upgrade until you run one. MicroK8s suits people who want Canonical to act as their platform team; k0s suits people who already have one.

This is part 3 of the Less than K8s series, after K3s or k3d and kind or minikube.

MicroK8s: Canonical keeps deciding after install#

MicroK8s ships as a snap published by Canonical, for amd64, arm64, ppc64el and s390x. You install it from a channel whose track is a Kubernetes minor version, add yourself to its group, and turn things on:

Shell
sudo snap install microk8s --classic --channel=1.35
sudo usermod -a -G microk8s $USER
microk8s status --wait-ready
microk8s enable dns hostpath-storage ingress

A fresh node runs Calico for networking and little else. Everything you would otherwise choose arrives as an addon: CoreDNS, a hostpath StorageClass that the docs themselves call unsuitable for production, MetalLB, metrics-server, an ingress controller. One command each, and each one is Canonical's pick.

The ingress addon shows what that costs. It used to deploy the NGINX ingress controller. From the 1.35 track onwards it deploys Traefik, and to keep existing manifests working it creates three IngressClasses: public, traefik, and nginx, which routes through Traefik and translates what the docs describe as "common" NGINX annotations. Part 1's warning was that annotations belong to the controller that reads them. On MicroK8s, an Ingress that says ingressClassName: nginx is read by Traefik, and nothing in the cluster tells you which annotations fell outside "common". If production runs a real NGINX-family controller, an Ingress that works here can still behave differently there, because annotations outside the translated set are ignored.

The second decision is timing. Snaps check for updates every six hours by default and apply them with no notification; for MicroK8s that means Kubernetes patch releases, dependency updates and addon fixes landing on a node that is serving traffic. The track stops it jumping a minor version, and that is the only guard you get without asking. On one node this is a convenience. On three, it is a cluster whose nodes can pick up a new revision on their own schedule, and your first sign is snap changes after one node starts behaving unlike its peers. Hold it, or give it a window:

Shell
sudo snap refresh --hold microk8s
sudo snap set system refresh.timer=fri5,22:00-23:00

A hold with no duration is indefinite, and a targeted snap refresh microk8s still goes through, so upgrades become something you run. For a fleet, Canonical's answer is a Snap Store Proxy, which holds revisions until you have tested them.

k0s: nothing you did not declare#

k0s is developed by the k0sproject community as a Linux Foundation project, with commercial support from Mirantis. It is one binary with no host dependencies beyond the kernel, built for x86-64, ARM64, ARMv7 and RISC-V:

Shell
curl --proto '=https' --tlsv1.2 -sSf https://get.k0s.sh | sudo sh
sudo k0s install controller --enable-worker --no-taints
sudo k0s start

The quick start uses --single instead, and the docs are plain about the trade: it disables what multi-node clusters need, so that node can never be joined by another. Use the line above for any box that might grow.

What you get is kube-router for networking, containerd, CoreDNS, metrics-server and Konnectivity, the tunnel the API server uses to reach kubelets so the control plane can sit on a network the workers cannot route back into. No ingress controller, no load balancer, no StorageClass. By default, controllers in a multi-node cluster run no kubelet and no container engine, so three controllers and no workers is a cluster that cannot run a pod.

Additions go in k0s.yaml. Charts listed under spec.extensions.helm become Chart resources that the controllers install, so the ingress controller is whichever one production runs, at the version you wrote down, in the same file as the cluster. Upgrades are equally explicit: stop, replace the binary, start; or set spec.k0s.version and run k0sctl apply, which upgrades controllers one at a time and drains workers in batches. Autopilot runs the same process from inside the cluster when you apply a Plan. Nothing on the machine changes between those runs.

Datastores, HA and the hardware#

K3s, from part 1, starts on SQLite and moves to embedded etcd with --cluster-init and an odd number of servers, three or more.

MicroK8s stores cluster state in dqlite, a Raft-replicated SQLite, and becomes highly available on its own once a third node joins through microk8s add-node: voter election and replication need no configuration. The price is that when the datastore misbehaves you are inside dqlite, and none of the etcd tooling, including the etcd backup and restore routine, applies.

k0s uses SQLite for a single node and etcd for multi-node, with MySQL or PostgreSQL as options. HA means three or five controllers and a TCP load balancer in front of the API, Konnectivity and join ports, or k0s's own control plane load balancing, which floats a Keepalived virtual IP between controllers. That is more to build than MicroK8s asks of you, and all of it is etcd and a load balancer, the parts you already know how to operate.

On hardware, the snap has no 32-bit ARM build, so an older Pi or a 32-bit OS rules MicroK8s out where k0s and K3s both run. MicroK8s also needs the memory cgroup enabled on the kernel command line on a Pi.

The diagram#

Who changes each cluster, and when. Open it in archhy and make a copy to mark up your own setup.

Which to put where#

A home lab of Pis is MicroK8s's best case, on a 64-bit OS. Three boards become an HA cluster with an add-node and a join each, addons get you from install to a working Ingress in an afternoon, and self-updating nodes are a feature when the cluster exists for learning. If the lab exists to rehearse your work clusters, the nginx class served by Traefik is the reason to install your own controller instead.

An edge fleet should be k0s or K3s. Boxes that each refresh from a public store on their own six-hourly clock make a fleet whose versions you learn from monitoring; with k0s, the version is a line in a file and nothing moves until you apply it. Choose K3s over k0s when its bundled Traefik, ServiceLB and local-path are what you would have installed anyway, as part 1 argued. Throwaway clusters for development are a different job, covered in part 2.

A single-node production box should be k0s, installed with --enable-worker --no-taints and with its ingress and storage declared in k0s.yaml, so the file describes the box and rebuilding it starts from that file. MicroK8s is a reasonable choice here only with the refresh held, at which point you have disabled the thing it does differently.