Local Kubernetes on Mac: a Multi-Node Cluster with UTM
Home
Archives
Search
Qstars IT
Werken bij
Contact
Dark Mode
Table of contents
Local Kubernetes on Mac: a Multi-Node Cluster with UTM
How to run a real multi-node Kubernetes cluster locally on macOS, using UTM and the QEMU hypervisor on Apple Silicon, with every technical detail covered.
Today we’re going to configure a Kubernetes cluster using virtual machines on our MacOS host. We are going to use UTM which utilises QEMU, a type-2 hypervisor to actually virtualise the new machines. I will be using a 2024 Macbook Pro with the Apple Silicon M4 chip, this guide can also be followed on older M-chips or Intel CPU’s.
Virtual Machines vs Dockerized Kubernetes
There is an abundance of easy to use tools out there to quickly spin up a local Kubernetes cluster. You may have heard of Minikube, KinD (Kubernetes-in-Docker) or K3S. Running Kubernetes inside actual VMs simulates a more realistic production environment. Each VM has their own kernel and networking stack, this doesn’t just offer a higher level of protection to your host machine it also allows us tighter controls over the OS & Kernel.
We’re going to be installing the Kubernetes (v1.32*) cluster using kubeadm, meaning that all of our control plane components are going to be running as Pods on the cluster (in the kube-system namespace, more about that later).
*At the time of writing, v1.32 is the latest minor release. Other minor versions can be installed following this guide, you just need to swap out the version numbers where specified. Learn more about Kubernetes versioning.
Prerequisites
Don’t know your CPU architecture? Run uname -m in a terminal of your choice.
๐ก Got an Apple Silicon M-chip (arm64)? Use aarch64 where there is no specific arm64 download available.
A MacOS machine (Intel or Apple Silicon)
UTM
Ubuntu Server & Alpine Linux Standard ISO files matching your cpu architecture
Installation
This section will cover the installation of three virtual machine types. The Router will provide internet & inter-node connectivity to our Kubernetes cluster, using a router like this will allow us to connect to any internet device without the inter-node network being disrupted (i.e by changing IP addresses or firewall rules).
The control plane and worker node(s) are standard Kubernetes components, in this guide we’ll install one worker and one dedicated control plane node. Repeat the installation steps to add more control plane or worker nodes to your cluster for high-avalability.
โThe amount of RAM (memory) is expressed in Mebibytes. The amount of processor cores refer to virtual CPU cores assigned to the VM. On Apple Silicon, these are distributed across efficiency and performance cores, while on Intel Macs, they may correspond to physical or logical hyperthreaded cores.
Router
Resource<br>Value
Operating system<br>Alpine Standard 3.21.3+
Memory<br>512 Mebibyte
Processor cores
Disk size<br>10 Gigabytes
Let’s get this party started by setting up our Router VM. Press the + icon in UTM and select Virtualize . On the next screen, select Linux
On the Linux virtualisation page we are going to leave Apple Virtualization & Boot from kernal image off. Press Browse... and select the Alpine ISO we have just downloaded.
Fill in the memory, CPU core requirements & storage as per the values above. Leave OpenGL acceleration turned off. We are going to skip the Shared Directory page.
Now you should be greeted with the Summary page, here you can review what we’ve just configured before spinning up the vm. Give it a name of your liking and press Save .
Before we can continue installing Alpine on the machine we have to add a Serial (terminal) output to the vm. Right click on the machine in the lefthand overview and press Edit .
Head over to the Devices tab, we are going to remove the primary Display that’s configured for the machine and instead add a Serial .
We’re ready to install Alpine Linux! Hit Save & press the play button to spin up our virtual machine. After waiting for some seconds you’ll be greeted with a login screen, login with the root username and no password.
We can begin the installation process by running the setup-alpine command in the terminal. We’ll be prompted by the setup wizard to configure a hostname, use a name that you’ll be able to identify the machine with, I choose router. For the Interface (networking) configuration, you can simply press enter. We want to configure the default interface to be assigned an IP address from our internet modem using DHCP.
Next, enter a memorable password for the root user. This is the most privileged user on the machine and it can perform any action, make it secure! After filling in your password you’ll be asked what timezone you’re from. From this part onwards, you can safely use the default values for sections Proxy , Network Time Protocol , APK...