One Apple Silicon Mac can run a three-node k3s cluster: three Ubuntu VMs in MacVisor, made from one cloud image, on a network of their own. The first runs the k3s server, the other two join it as agents with its token, and kubectl on your Mac reaches it by name.
Each VM is a linked clone of the same Ubuntu image, so it stores only what it writes. Nested virtualization isn't needed: k3s runs containers, not VMs, so any M-series Mac will do, not only M3 and later. If a single node is all you need, see the last section.
What you need
- MacVisor on an Apple Silicon Mac with macOS 27. Guests are ARM64 only, and k3s supports ARM64.
- Memory for three VMs: 4 GiB for the server and 2 GiB for each agent. k3s lists a minimum of 2 cores and 2 GB for a server, and 1 core and 512 MB for an agent. MacVisor's docs ask for at least 4 GiB for a VM made with
--runtime k3s, which runs a server, so the server here gets the same. - Room for that 8 GiB beside macOS and your apps. MacVisor lets running VMs add up to more memory than the Mac has, and flags it, but macOS then swaps. vCPUs can be overcommitted, and each VM gets 4 by default.
kubectlon the Mac.
1. Create a network for the cluster
mvz networks create cluster
A custom network is a private segment. This one is shared: its VMs reach each other directly, and the internet through the Mac, for k3s and container images. Only this Mac can reach them. macOS picks the subnet when the first VM starts on it. See Custom networks.
2. Make three Ubuntu nodes from one cloud image
mvz create ubuntu k3s-1 --network cluster --memory 4 --no-forward
mvz create ubuntu k3s-2 --network cluster --memory 2 --no-forward
mvz create ubuntu k3s-3 --network cluster --memory 2 --no-forward
mvz start k3s-1 k3s-2 k3s-3 --headless
mvz wait k3s-1 && mvz wait k3s-2 && mvz wait k3s-3
ubuntu is Ubuntu 26.04 LTS for ARM64. MacVisor downloads Canonical's cloud image once and keeps it as a template, and each VM is a linked clone of that template: it reads the shared image and writes only its own changes. On the first boot, cloud-init sets each one up with your account, your SSH keys, the MacVisor Agent, and a hostname taken from the VM's name. k3s needs a unique hostname on every node, and k3s-1, k3s-2 and k3s-3 are. mvz wait returns once cloud-init has finished.
--no-forward keeps the nodes' ports off your Mac's localhost. Without it, MacVisor would forward the server's API port, 6443, to 127.0.0.1:6443, which only one VM can hold. Here you reach the cluster over its network instead, as you would a cluster of real machines.
3. Pin each node's address
MacVisor gives every cloud-image VM on a custom network a DHCP reservation of its own, from the top of the subnet down, once the subnet is known. On a new network that's after its first VM has started, so these reservations wait until the network is made again. Put them in force now, before the agents are pointed at the server's address:
mvz networks apply cluster # unplugs the VMs for a few seconds; they come back on their reserved addresses
mvz networks # the subnet, and each reservation
To choose an address yourself, mvz networks reserve cluster k3s-1 <ip> replaces the automatic one, and also takes effect with apply. See DHCP reservations.
4. Install the k3s server
k3s's install script sets k3s up as a service that starts again after a reboot. Run it in k3s-1, adding the node's .mvz name to the API server's certificate so kubectl on the Mac can use that name:
mvz exec k3s-1 "curl -sfL https://get.k3s.io | sh -s - --tls-san k3s-1.mvz"
Given one quoted argument, mvz exec runs it through the guest's shell, so the pipe happens in the VM. The script also installs kubectl in the guest, and writes the cluster's kubeconfig to /etc/rancher/k3s/k3s.yaml.
5. Join the two agents
An agent needs the server's URL and its token, which the server keeps in /var/lib/rancher/k3s/server/node-token. With K3S_URL set, the same script installs an agent instead of a server:
SERVER=$(mvz ip k3s-1 --wait)
TOKEN=$(mvz exec k3s-1 -- sudo cat /var/lib/rancher/k3s/server/node-token)
for node in k3s-2 k3s-3; do
mvz exec "$node" "curl -sfL https://get.k3s.io | K3S_URL=https://$SERVER:6443 K3S_TOKEN=$TOKEN sh -"
done
mvz exec k3s-1 -- sudo kubectl get nodes
The agents join by the server's address, which the reservation keeps fixed. get nodes lists all three once the agents have registered.
For a fourth node, create and start k3s-4 like the others, run mvz networks apply cluster for its reservation, then the same join command.
6. Use kubectl from your Mac
k3s writes its kubeconfig owned by root, with mode 600. Copy it to the Mac and point its server field at the node:
mkdir -p ~/.kube
mvz exec k3s-1 -- sudo cat /etc/rancher/k3s/k3s.yaml \
| sed 's#server: .*#server: https://k3s-1.mvz:6443#' > ~/.kube/k3s-cluster.yaml
export KUBECONFIG=~/.kube/k3s-cluster.yaml
kubectl get nodes -o wide
k3s-1.mvz resolves on the Mac to the node's address, and the certificate has that name from --tls-san. kubectl connects over the network, so your terminal app needs the Local Network permission, in System Settings โ Privacy & Security โ Local Network. See No route to host.
The kubeconfig's client certificate is valid for a year. k3s renews certificates that are within 120 days of expiring each time it starts, but your copy on the Mac keeps the old one, so copy the file again after a renewal.
Which ports does k3s need?
| Port | From | To | For |
|---|---|---|---|
| TCP 6443 | Agents | Server | The k3s supervisor and the Kubernetes API |
| UDP 8472 | All nodes | All nodes | Flannel VXLAN |
| TCP 10250 | All nodes | All nodes | Kubelet metrics and API |
These come from k3s's requirements. TCP 2379 and 2380 matter only with several servers and embedded etcd.
All of this is traffic between VMs on the same network, and MacVisor's network firewall never sees that: it never leaves the network's virtual switch. So with the firewall on, the nodes keep talking, and only what comes from the Mac needs a rule:
mvz networks firewall cluster on --inbound deny --outbound allow --allow in:tcp:6443
That lets kubectl in and refuses other connections from the Mac, SSH included. mvz exec reaches the VM through the MacVisor Agent's tunnel, not the network, so it keeps working. Outbound stays open, so the nodes can still pull images. The firewall filters IPv4 only, and drops IPv6 on the network while it's on.
For NodePort services, add a rule for k3s's default range. --allow adds to the rules already there:
mvz networks firewall cluster --allow in:tcp:30000-32767
Snapshot the nodes before an upgrade
for node in k3s-1 k3s-2 k3s-3; do
mvz snapshots take "$node" --disk-only --name before-upgrade
done
MacVisor has each guest flush its writes to disk before the snapshot, and a disk-only snapshot is kept across macOS and MacVisor updates.
Then upgrade the way k3s documents it: run the install script again with the same options as the first time, on the server first and then on the agents. INSTALL_K3S_VERSION picks a release, and k3s asks you not to skip a minor version. If the cluster doesn't come back, put all three nodes back together:
for node in k3s-1 k3s-2 k3s-3; do
mvz snapshots revert "$node" before-upgrade --yes # powers off and restores the disk
done
mvz start k3s-1 k3s-2 k3s-3 --headless
Snapshots live inside each VM, so they aren't a backup. Backups copy whole VMs to another drive, while they run.
Just one node? Use --runtime k3s
mvz create ubuntu k8s --runtime k3s --memory 8
mvz kubeconfig k8s --save --start
KUBECONFIG=~/.kube/macvisor-k8s.yaml kubectl get nodes
With --runtime k3s, cloud-init installs a single-node k3s, pinned to v1.36.5+k3s1, and mvz kubeconfig writes a kubeconfig for its API server, forwarded to 127.0.0.1:6443. Only one running VM can hold that port, so run one such VM at a time. The cluster above doesn't use it, so the two can run side by side. Docker and Kubernetes on a Mac without Docker Desktop has more.
Try it
Download MacVisor for a free 30-day trial, with every single-Mac feature. A one-time Pro license covers one or two Macs.
DeltaSync