How to properly run k3s on MacOS

TL;DR:

Go here, follow the instructions

or

brew install k3d && k3d create && k3d get-kubeconfig --name='k3s-default'

I love using MacOS. In my job, at least. It strikes the right balance with me regarding stability, battery life and being supported (properly) by all of the tooling that I use in my day to day job.

I love Linux. But I’ll never forget that one time my external monitor suddenly stopped working and the only solution was to install a mainline kernel. I lost a whole day of work on that one.


When I’m testing out something in Kubernetes, I usually use a small cluster in a private cloud I have access to. However, it is very useful to be able to launch pods locally.

Back in the day I used minikube for this. It works fine, but my laptop is a two-core machine, and having minikube on means it starts blowing fans and burning my lap.


While looking for an alternative I came across K3S which is a single static binary that implements the K8S API while stripping down a lot of stuff you don’t use.

Unfortunately I was saddened to read that, at least at first glance, k3s does not run on MacOS.

I started immediately thinking of ways of running this on MacOS, which inevitably lead to thinking about the lightest way of running a VM: having a heavy VM running on VirtualBox would negate any benefit of running a trimmed down version of Kubernetes.

This is a solved issue. Docker for Mac uses a lightweight linuxkit-based VM to run Docker.

Luckily, we don’t need to go through the trouble of booting our own VM and set up networking and other stuff (unless we don’t want to, it’s kinda fun) when we can piggyback on the one provided by Docker. This project, k3d, runs k3s inside docker. The instructions work out of the box, and set up a k3s cluster.

You just have to follow the instructions and presto:

$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                      READY   STATUS      RESTARTS   AGE
kube-system   local-path-provisioner-58fb86bdfd-p7jcv   1/1     Running     0          97m
kube-system   metrics-server-6d684c7b5-w7t7l            1/1     Running     0          97m
kube-system   helm-install-traefik-9h622                0/1     Completed   0          97m
kube-system   coredns-d798c9dd-5br8m                    1/1     Running     0          97m
kube-system   svclb-traefik-btjht                       3/3     Running     0          96m
kube-system   traefik-65bccdc4bd-k6q47                  1/1     Running     0          96m