Join a Mac Mini to k3s with Lima
Wiki: How to join an Apple M4 Mac Mini to an existing K3s cluster using Lima VM, socat port forwarding, and a single shared IP.
Overview¶
Since macOS cannot run K3s natively (Linux only), we run a Lima VM (Debian 12) inside the Mac Mini and join it to the cluster as a worker node. Because Lima uses NAT networking, we use socat as a port proxy and a shared IP (<MAC_MINI_IP>) on both the Mac Mini's Ethernet interface and the Lima VM's internal interface to make the VM fully visible on the LAN.
LAN (<HOME_LAN_CIDR>)
├── castis-desktop <CASTIS_DESKTOP_IP> control-plane
├── nuc-a <NUC_A_IP> control-plane
├── nuc-b <NUC_B_IP> control-plane
└── mac-mini <MAC_MINI_IP> macOS host (en0)
└── Lima VM <LIMA_VM_IP> vzNAT internal
<MAC_MINI_IP> /32 alias on lima0 (kubelet validation only)
Key IPs¶
| Host | Interface | IP | Role |
|---|---|---|---|
| Mac Mini | en0 |
<MAC_MINI_IP> |
Primary LAN IP — ARP + NAT ownership |
| Lima VM | lima0 |
<LIMA_VM_IP> |
vzNAT internal IP |
| Lima VM | lima0 |
<MAC_MINI_IP>/32 |
Kubelet validation only — no ARP, no MAC |
Concept Deep Dive¶
Understanding why each piece exists prevents confusion when troubleshooting.
What is FDB¶
FDB = Forwarding DataBase — a kernel table managed by flannel on each node.
It maps overlay MAC → physical tunnel destination IP:
# On NUC-B
bridge fdb show dev flannel.1
<MAC_MINI_FLANNEL_MAC> dst <MAC_MINI_IP> ← mac-mini's flannel.1 MAC → Mac Mini IP
<NUC_A_FLANNEL_MAC> dst <NUC_A_IP> ← nuc-a's flannel.1 MAC → NUC-A IP
<CASTIS_DESKTOP_FLANNEL_MAC> dst <CASTIS_DESKTOP_IP> ← castis-desktop flannel.1 MAC → its IP
Think of it as:
ARP table = "node IP → node MAC" (physical LAN layer)
FDB table = "pod MAC → node IP" (VXLAN overlay layer)
FDB bridges the overlay world (pods) to the physical world (nodes).
Two Separate MAC Worlds¶
Every VXLAN packet contains two sets of MACs:
┌─────────────────────────────────────┐
│ Ethernet: <MAC> → <MAC> │ ← physical MACs (en0, real hardware)
├─────────────────────────────────────┤
│ UDP: <MAC_MINI_IP> → <NUC_A_IP>:8472 │ ← physical IPs
├─────────────────────────────────────┤
│ VXLAN header │
├─────────────────────────────────────┤
│ Ethernet: <MAC> → <MAC> │ ← overlay MACs (flannel.1, virtual)
├─────────────────────────────────────┤
│ IP: <MAC_MINI_POD_IP> → <NUC_POD_IP> │ ← pod IPs
└─────────────────────────────────────┘
| MAC | Interface | Purpose |
|---|---|---|
<MAC_MINI_EN0_MAC> |
en0 |
Physical — send Ethernet frame on real LAN |
<MAC_MINI_FLANNEL_MAC> |
flannel.1 |
Overlay — identify mac-mini node in VXLAN |
MAC is always about ARP — just at different network layers.
How Flannel Learns About New Nodes¶
Flannel uses Kubernetes API watch — NOT broadcast, NOT polling:
Flannel on each NUC opens ONE persistent connection to API server:
"notify me whenever a Node object changes"
│
│ persistent watch connection
▼
API Server (etcd backed)
When mac-mini joins:
k3s-agent registers node object
↓
API server pushes event to ALL watchers simultaneously
↓
NUC-A flannel receives
NUC-B flannel receives
castis-desktop flannel receives
↓
Each NUC updates FDB instantly
No periodic polling — purely event-driven. Scales to thousands of nodes.
How Flannel Determines public-ip¶
k3s-agent starts
↓
reads /etc/rancher/k3s/config.yaml → node-ip: <MAC_MINI_IP>
↓
kubelet validates: "does <MAC_MINI_IP> exist on ANY interface?"
scans: lo, eth0, lima0
lima0 has <MAC_MINI_IP>/32
↓
kubelet registers node:
InternalIP = <MAC_MINI_IP>
↓
flannel reads InternalIP from node object
↓
flannel writes annotation:
flannel.alpha.coreos.com/public-ip = <MAC_MINI_IP>
↓
all NUCs watching API update FDB:
9e:94:... → dst <MAC_MINI_IP>
Priority order:
1. flannel.alpha.coreos.com/public-ip annotation ← if explicitly set
2. InternalIP from node object ← auto-derived (normal path)
If you manually annotate public-ip, flannel will overwrite it on next restart by re-deriving from InternalIP. The only permanent fix is to set the correct node-ip in config.yaml.
Why lima0 /32 Exists — Validation Only¶
<MAC_MINI_IP>/32 on lima0 has one single purpose:
kubelet asks: "does <MAC_MINI_IP> exist on any interface?"
lima0 /32 answers: "yes"
↓
kubelet accepts config.yaml node-ip
↓
registers correct InternalIP
↓
flannel gets correct public-ip
Without it:
kubelet validation fails
↓
ignores config.yaml node-ip
↓
auto-detects <LIMA_VM_IP> instead
↓
flannel registers wrong IP
↓
NUC FDB points to unreachable IP
lima0 /32 has NO MAC address of its own, does NO ARP, is invisible to the LAN. It is purely a validation token.
Why en0 Must Own the Same IP¶
en0 needs .17 for two reasons:
1. Inbound ARP:
NUC FDB says: "send VXLAN to <MAC_MINI_IP>"
NUC asks ARP: "who has <MAC_MINI_IP>?"
en0 answers: "<MAC_MINI_EN0_MAC>"
Packet physically arrives at Mac Mini
2. Outbound NAT ownership:
Lima VM flannel sends reply:
outer src: <MAC_MINI_IP> ← from lima0 /32
Mac Mini NAT checks: "do I own <MAC_MINI_IP>?"
en0 has <MAC_MINI_IP> → routes out en0 correctly
NUC receives from <MAC_MINI_IP> ← matches FDB
Without en0 .17 — inbound ARP fails (nobody answers) and outbound NAT fails (wrong source IP).
Why /32 Not /24 on lima0¶
/24 on lima0:
adds route: <HOME_LAN_CIDR> → via lima0
Lima VM tries to reach NUCs via lima0 directly
breaks default NAT route via <LIMA_NAT_GATEWAY_IP>
/32 on lima0:
adds only host route: <MAC_MINI_IP> → lima0
everything else still routes via <LIMA_NAT_GATEWAY_IP>
NUCs still reachable via NAT
Why socat Instead of pf/pfctl¶
macOS pf rdr rules cannot redirect traffic destined for the host's own IP — kernel limitation. socat works at the application layer, bypassing this entirely:
pf rdr: kernel level, cannot intercept own-IP traffic
socat: application level, just listens on a port and pipes data
InternalIP vs ExternalIP¶
InternalIP → set by kubelet from config.yaml node-ip
used by flannel for public-ip derivation
used by cluster-internal communication
ExternalIP → set by kubelet from config.yaml node-external-ip
optional — only needed if InternalIP is wrong/unreachable
used by metrics-server as fallback address
In our final setup both are the same IP — ExternalIP is redundant and can be removed by deleting node-external-ip from config.yaml.
Normal Node vs Mac Mini Lima VM¶
Normal node (NUC):
interface IP == LAN IP
flannel auto-detects correctly
no config needed
Mac Mini Lima VM:
interface IP (<LIMA_VM_IP>) ≠ LAN IP (<MAC_MINI_IP>)
flannel auto-detects WRONG IP
must manually override via config.yaml
must add /32 alias so kubelet accepts the override
Everything complex in this setup exists because of this single mismatch.
Traffic Flow¶
Full Boot-to-Working Sequence¶
Phase 1: macOS boots
en0 gets <MAC_MINI_IP> (from networksetup static config)
Gratuitous ARP sent: "<MAC_MINI_IP> = <MAC_MINI_EN0_MAC>"
All NUCs cache this ARP entry
Phase 2: Lima VM starts (30s delay)
vzNAT assigns lima0 = <LIMA_VM_IP>
default route: <LIMA_NAT_GATEWAY_IP> (Mac Mini)
Phase 3: lima-ip-alias.service
ip addr add <MAC_MINI_IP>/32 dev lima0
NO ARP sent (behind NAT, /32 host route only)
purely for kubelet validation
Phase 4: socat starts (waits for Lima VM ping)
binds on <MAC_MINI_IP>:10250 → <LIMA_VM_IP>:10250
binds on <MAC_MINI_IP>:8472 → <LIMA_VM_IP>:8472
Mac Mini becomes transparent proxy
Phase 5: k3s-agent starts
reads config.yaml: node-ip = <MAC_MINI_IP>
kubelet validates: lima0 has <MAC_MINI_IP>/32
registers: InternalIP = <MAC_MINI_IP>
connects to API server via NAT (<LIMA_NAT_GATEWAY_IP> → en0 → LAN)
Phase 6: flannel sets up VXLAN
reads InternalIP = <MAC_MINI_IP>
writes public-ip annotation = <MAC_MINI_IP>
creates flannel.1 (MAC: <MAC_MINI_FLANNEL_MAC>)
all NUCs receive event via API watch
NUCs update FDB: 9e:94:... → dst <MAC_MINI_IP>
Inbound: NUC pod → Mac Mini pod¶
NUC pod wants to reach <MAC_MINI_POD_IP> (mac-mini pod)
↓
NUC flannel route: <MAC_MINI_POD_CIDR> → flannel.1
↓
overlay ARP: "who has <MAC_MINI_POD_IP>?" → mac-mini pod MAC
↓
FDB lookup: pod MAC → dst <MAC_MINI_IP>
↓
NUC checks ARP: "who has <MAC_MINI_IP>?"
→ already cached: <MAC_MINI_EN0_MAC> (from boot)
↓
NUC sends Ethernet frame to <MAC_MINI_EN0_MAC>
outer UDP: src=<NUC_A_IP> dst=<MAC_MINI_IP>:8472
inner: <NUC_POD_IP> → <MAC_MINI_POD_IP>
↓
Mac Mini en0 receives (owns <MAC_MINI_IP>)
↓
socat: <MAC_MINI_IP>:8472 → <LIMA_VM_IP>:8472
↓
Lima VM flannel.1 unwraps VXLAN
↓
Mac Mini pod receives
Outbound: Mac Mini pod → NUC pod¶
Mac Mini pod replies
↓
Lima VM flannel wraps in VXLAN:
outer src: <MAC_MINI_IP> ← lima0 has /32 so flannel uses it
outer dst: <NUC_A_IP>:8472
↓
Lima VM routing: <NUC_A_IP> → default → <LIMA_NAT_GATEWAY_IP>
↓
Packet goes to Mac Mini host
↓
Mac Mini NAT: "do I own <MAC_MINI_IP>?"
en0 has <MAC_MINI_IP> → sends out en0
↓
NUC receives from <MAC_MINI_IP>
FDB: mac-mini = <MAC_MINI_IP> matches
↓
NUC pod receives reply
Metrics: metrics-server → kubelet¶
metrics-server (on NUC) scrapes https://<MAC_MINI_IP>:10250
↓
Mac Mini en0 receives (owns <MAC_MINI_IP>)
↓
socat: <MAC_MINI_IP>:10250 → <LIMA_VM_IP>:10250
↓
Lima VM kubelet responds with CPU/RAM stats
↓
socat returns response to metrics-server
ARP Trigger — When Does NUC Ask for ?¶
ARP for .17 is only triggered when a NUC pod actually wants to send a packet to a mac-mini pod:
Setup phase: IP in config/annotation/FDB — no ARP needed yet
First packet: NUC tries to send VXLAN to <MAC_MINI_IP>
ARP triggered: "who has <MAC_MINI_IP>?"
en0 answers (or fails if en0 doesn't have <MAC_MINI_IP>)
This is why the setup appears to work (cluster shows Ready, annotations correct) but only breaks when the first real packet is sent. Everything looks fine until ARP is actually needed.
Prerequisites¶
- Mac Mini with macOS (Apple Silicon, M4)
- Existing K3s cluster with known server IP and node token
- Mac Mini connected via Ethernet to same LAN as cluster nodes
- Resources: 10 CPU cores, 32GB RAM, 926GB disk available
Step 1 — Mac Mini Network Setup¶
Set <MAC_MINI_IP> as the primary static IP on Ethernet:
sudo networksetup -setmanual Ethernet <MAC_MINI_IP> 255.255.255.0 <LAN_GATEWAY_IP>
sudo networksetup -setdnsservers Ethernet <PUBLIC_DNS_1_IP> <PUBLIC_DNS_2_IP>
Verify¶
Note: Do this from local console (VNC/screen) not SSH — you will lose your SSH connection when the IP changes.
Step 2 — Install Homebrew, Lima, socat¶
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
# Install Lima and socat
brew install lima socat
Step 3 — Create Lima VM¶
mkdir -p ~/.lima/k3s-agent
cat > ~/.lima/k3s-agent/lima.yaml << 'EOF'
vmType: vz
vmOpts:
vz:
rosetta:
enabled: true
binfmt: true
cpus: 6
memory: 16GiB
disk: 500GiB
images:
- location: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-arm64.qcow2"
arch: aarch64
networks:
- vzNAT: true
EOF
limactl start ~/.lima/k3s-agent/lima.yaml
# When prompted: select "Proceed with the current configuration"
Note: Lima instance will be named
lima(notk3s-agent) — this is expected.
Step 4 — Get K3s Cluster Info¶
Run on an existing cluster node:
# Get node token
sudo cat /var/lib/rancher/k3s/server/node-token
# Get server IP
kubectl get nodes -o wide
Step 5 — Install K3s Agent Inside Lima VM¶
Write config BEFORE installing — K3s reads it during install:
limactl shell lima -- sudo mkdir -p /etc/rancher/k3s
limactl shell lima -- sudo tee /etc/rancher/k3s/config.yaml << 'EOF'
node-name: mac-mini
node-ip: <MAC_MINI_IP>
node-label:
- kubernetes.io/arch=arm64
- node-type=apple-silicon
EOF
Note: No
node-external-ipneeded —InternalIPis already correct.
# Install K3s agent (replace SERVER_IP and NODE_TOKEN)
limactl shell lima -- sudo sh -c 'curl -sfL https://get.k3s.io | \
K3S_URL=https://<SERVER_IP>:6443 \
K3S_TOKEN=<NODE_TOKEN> \
sh -s - agent'
Step 6 — Fix K3s Agent Service File¶
K3s installer writes reserved labels into the service file causing kubelet to crash. Fix it and make it immutable:
limactl shell lima -- sudo chattr -i /etc/systemd/system/k3s-agent.service 2>/dev/null; \
limactl shell lima -- sudo tee /etc/systemd/system/k3s-agent.service << 'EOF'
[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
Wants=network-online.target
After=network-online.target
After=lima-ip-alias.service
[Install]
WantedBy=multi-user.target
[Service]
Type=notify
EnvironmentFile=-/etc/default/%N
EnvironmentFile=-/etc/sysconfig/%N
EnvironmentFile=-/etc/systemd/system/k3s-agent.service.env
KillMode=process
Delegate=yes
User=root
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStartPre=-/bin/sh -c '/usr/bin/pkill -9 containerd-shim; sleep 2'
ExecStart=/usr/local/bin/k3s agent
EOF
limactl shell lima -- sudo chattr +i /etc/systemd/system/k3s-agent.service
limactl shell lima -- sudo systemctl daemon-reload
limactl shell lima -- sudo systemctl restart k3s-agent
Why immutable? K3s install script regenerates service file with original flags on every reinstall.
chattr +iprevents even root from modifying it.
Step 7 — Add IP Alias Inside Lima VM (Persistent)¶
Add <MAC_MINI_IP>/32 to lima0 so kubelet can validate node-ip from config.yaml:
limactl shell lima -- sudo tee /etc/systemd/system/lima-ip-alias.service << 'EOF'
[Unit]
Description=Add IP alias for K3s kubelet validation
After=network.target
Before=k3s-agent.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c '/sbin/ip addr add <MAC_MINI_IP>/32 dev lima0 2>/dev/null || true'
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
limactl shell lima -- sudo systemctl enable lima-ip-alias
limactl shell lima -- sudo systemctl start lima-ip-alias
Verify¶
limactl shell lima -- ip addr show lima0 | grep inet
# Should show:
# inet <LIMA_VM_IP>/24 ← vzNAT
# inet <MAC_MINI_IP>/32 ← validation alias (no ARP, no MAC)
Why /32 not /24? /24 would route all of
<HOME_LAN_CIDR>throughlima0, breaking the default NAT gateway. /32 adds only a host route for.17itself — purely for kubelet to find it during validation.
Step 8 — Setup Socat Port Proxies (Persistent)¶
Socat bridges K3s ports between <MAC_MINI_IP> (LAN-visible) and <LIMA_VM_IP> (Lima VM):
cat > ~/k3s-socat.sh << 'EOF'
#!/bin/bash
LIMA_IP="<LIMA_VM_IP>"
HOST_IP="<MAC_MINI_IP>"
SOCAT="/opt/homebrew/bin/socat"
echo "Waiting for Lima VM..."
until ping -c 1 -W 1 ${LIMA_IP} > /dev/null 2>&1; do
sleep 5
done
echo "Lima VM is up"
$SOCAT TCP-LISTEN:10250,bind=${HOST_IP},fork,reuseaddr TCP:${LIMA_IP}:10250 &
$SOCAT TCP-LISTEN:10255,bind=${HOST_IP},fork,reuseaddr TCP:${LIMA_IP}:10255 &
$SOCAT UDP-RECVFROM:8472,bind=${HOST_IP},fork,reuseaddr UDP:${LIMA_IP}:8472 &
$SOCAT UDP-RECVFROM:51820,bind=${HOST_IP},fork,reuseaddr UDP:${LIMA_IP}:51820 &
echo "All K3s socat proxies started"
wait
EOF
chmod +x ~/k3s-socat.sh
cat > ~/Library/LaunchAgents/io.socat.k3s.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.socat.k3s</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/non/k3s-socat.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/k3s-socat.log</string>
<key>StandardErrorPath</key>
<string>/tmp/k3s-socat.log</string>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/io.socat.k3s.plist
Port mapping¶
| Port | Protocol | Purpose |
|---|---|---|
10250 |
TCP | Kubelet API — metrics, logs, exec |
10255 |
TCP | Kubelet read-only |
8472 |
UDP | Flannel VXLAN — pod-to-pod networking |
51820 |
UDP | Flannel WireGuard |
Step 9 — Lima VM Auto-Start (Persistent)¶
cat > ~/Library/LaunchAgents/io.lima.k3s-agent.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.lima.k3s-agent</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>sleep 30 && /opt/homebrew/bin/limactl start lima</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/io.lima.k3s-agent.plist
Step 10 — Fix Metrics Server (Permanent)¶
kubectl patch deployment metrics-server -n kube-system --type=strategic -p '{
"spec": {
"template": {
"spec": {
"containers": [{
"name": "metrics-server",
"args": [
"--cert-dir=/tmp",
"--secure-port=10250",
"--kubelet-preferred-address-types=ExternalIP,InternalIP,Hostname",
"--kubelet-use-node-status-port",
"--metric-resolution=15s",
"--kubelet-insecure-tls"
]
}]
}
}
}
}'
Step 11 — Enable Auto Power-On After Power Failure¶
sudo systemsetup -setrestartpowerfailure on
sudo systemsetup -getrestartpowerfailure
# Should show: Restart After Power Failure: On
Step 12 — Disable Sleep (Critical for Cluster Node)¶
A cluster node must never sleep. When macOS sleeps, the Lima VM pauses and kubelet stops sending heartbeats — the cluster marks the node NotReady and tries to reschedule pods, causing disruption.
# Disable all sleep
sudo pmset -a sleep 0
sudo pmset -a disksleep 0
sudo pmset -a displaysleep 0
sudo pmset -a powernap 0
# Verify
pmset -g
# sleep, disksleep, displaysleep should all show 0
Also enable SSH (critical for remote management)¶
Without SSH you can only manage the Mac Mini via VNC — which requires being on the same LAN and having no session conflicts:
sudo systemsetup -setremotelogin on
sudo systemsetup -getremotelogin
# Should show: Remote Login: On
After this you can always reach Mac Mini from NUC-B:
What happens when Mac Mini sleeps¶
macOS goes to sleep
↓
Lima VM pauses (frozen)
↓
k3s-agent stops sending heartbeat
↓
cluster waits 40s → marks node NotReady
↓
taints added: node.kubernetes.io/unreachable:NoSchedule
node.kubernetes.io/unreachable:NoExecute
↓
pods evicted and rescheduled on other nodes ← disruption
↓
when Mac Mini wakes up:
Lima VM resumes
k3s-agent reconnects
node becomes Ready again
but evicted pods already moved ← inconsistent state
Recovery after accidental sleep¶
# Check node status
kubectl get nodes
kubectl describe node mac-mini | grep -A5 Conditions
# If NotReady — restart k3s-agent
ssh non@<MAC_MINI_IP> "limactl shell lima -- sudo systemctl restart k3s-agent"
# Watch recovery
kubectl get nodes -w
Step 13 — Longhorn Configuration (If Using Longhorn)¶
Install iSCSI (Required)¶
The Lima VM needs open-iscsi installed. Without it, longhorn-manager will crash with:
# Install open-iscsi inside Lima VM
limactl shell lima -- sudo apt-get install -y open-iscsi
# Enable and start iscsid service
limactl shell lima -- sudo systemctl enable iscsid
limactl shell lima -- sudo systemctl start iscsid
# Verify
limactl shell lima -- sudo systemctl status iscsid | grep Active
# Should show: active (running)
limactl shell lima -- sudo systemctl is-enabled iscsid
# Should show: enabled
Disable Longhorn Replica Scheduling on mac-mini (Critical)¶
mac-mini should be a compute node only — not a Longhorn storage node. Longhorn replicas should live on stable bare-metal NUCs.
Why mac-mini is not suitable for Longhorn replicas:
Longhorn replica on mac-mini:
NUC needs to connect to replica port (10000-10999)
↓
goes through socat proxy
↓
socat doesn't forward ports 10000-10999 ← problem
↓
replica rebuild fails
↓
volume stays degraded
↓
pods waiting for volume never start
Fix — disable replica scheduling on mac-mini:
kubectl patch node.longhorn.io mac-mini -n longhorn-system \
--type=merge \
-p '{"spec":{"allowScheduling":false}}'
Verify:
kubectl get node.longhorn.io mac-mini -n longhorn-system -o yaml | grep allowScheduling
# Should show: allowScheduling: false
Note: This only prevents NEW replicas from being created on mac-mini. Existing pods on mac-mini can still USE Longhorn volumes — they just read/write from replicas stored on NUCs. Think of mac-mini as a client, not a server for Longhorn storage.
Storage Strategy for mac-mini¶
Critical stateful workloads (databases, etcd):
→ Use longhorn-retain on NUCs
→ Never schedule on mac-mini
Stateful but recoverable (caches, queues):
→ Use local-path-retain on mac-mini
→ Fast local I/O, no port forwarding needed
Stateless workloads:
→ No PVC needed
→ Just run the pod
Use local-path-retain for mac-mini local storage:
# PVC example for mac-mini local storage
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-local-pvc
spec:
storageClassName: local-path-retain
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
Restart Longhorn manager after installing iSCSI¶
kubectl delete pod -n longhorn-system -l app=longhorn-manager \
--field-selector spec.nodeName=mac-mini
# Watch recovery
kubectl get pods -n longhorn-system | grep mac-mini
If Longhorn volume is stuck degraded on mac-mini¶
This happens when a pod gets scheduled on mac-mini and Longhorn tries to create a replica there but can't complete the rebuild:
# Check which replicas are on mac-mini
kubectl get replicas -n longhorn-system | grep mac-mini
# Delete mac-mini replicas — Longhorn will recreate on NUCs
kubectl delete replica <replica-name> -n longhorn-system
# If volume attachment stuck — check finalizer
kubectl get volumeattachment | grep <pvc-id>
kubectl patch volumeattachment <attachment-name> \
-p '{"metadata":{"finalizers":[]}}' \
--type=merge
# Force delete stuck pod and let it reschedule
kubectl delete pod <pod-name> -n <namespace> --force --grace-period=0
Verify all Longhorn pods healthy on mac-mini¶
kubectl get pods -o wide -n longhorn-system | grep mac-mini
# Should show: Running (not CrashLoopBackOff)
kubectl get pods -o wide --all-namespaces | grep mac-mini
# All should show Running
Verification¶
# 1. All nodes Ready?
kubectl get nodes
# 2. Metrics working?
kubectl top nodes
# 3. Correct IP — no ExternalIP?
kubectl get nodes -o wide
# mac-mini should show: InternalIP=<MAC_MINI_IP> ExternalIP=<none>
# 4. Flannel public-ip correct?
kubectl get node mac-mini -o jsonpath='{.metadata.annotations}' | python3 -m json.tool | grep public-ip
# Expected: "flannel.alpha.coreos.com/public-ip": "<MAC_MINI_IP>"
# 5. Pod-to-pod networking?
kubectl run test --image=nginx --overrides='{"spec":{"nodeSelector":{"node-type":"apple-silicon"}}}'
sleep 30
POD_IP=$(kubectl get pod test -o jsonpath='{.status.podIP}')
kubectl run pingtest --image=busybox --rm -it --restart=Never \
--overrides='{"spec":{"nodeSelector":{"node-type":"nuc"}}}' \
-- ping -c 3 $POD_IP
# Expected: 0% packet loss
Boot Sequence¶
Mac Mini powers on
│
▼
macOS network stack
→ en0 = <MAC_MINI_IP> (from networksetup static config)
→ Gratuitous ARP: "<MAC_MINI_IP> = <MAC_MINI_EN0_MAC>"
→ all NUCs cache this ARP entry
│
▼
io.lima.k3s-agent (LaunchAgent, 30s delay)
→ limactl start lima
→ Lima VM boots, lima0 = <LIMA_VM_IP> (vzNAT DHCP)
│
▼
io.socat.k3s (LaunchAgent)
→ waits until ping <LIMA_VM_IP> succeeds
→ binds socat proxies on <MAC_MINI_IP>
│
▼ (inside Lima VM)
lima-ip-alias.service
→ ip addr add <MAC_MINI_IP>/32 dev lima0
→ no ARP, no MAC — just satisfies kubelet validation
│
▼
k3s-agent.service
→ pkill containerd-shim (cleanup stale processes)
→ reads config.yaml: node-ip = <MAC_MINI_IP>
→ kubelet validates: lima0 has <MAC_MINI_IP>/32
→ registers: InternalIP = <MAC_MINI_IP>
→ flannel derives: public-ip = <MAC_MINI_IP>
→ NUCs update FDB: 9e:94:... → dst <MAC_MINI_IP>
→ cluster ready
Day-to-Day Management¶
# SSH into Mac Mini
ssh non@<MAC_MINI_IP>
# Drop into Lima VM
limactl shell lima
# One-liner: Lima VM from any machine
ssh -t non@<MAC_MINI_IP> limactl shell lima
# Lima VM status
limactl list
# Socat status
launchctl list | grep socat
netstat -an | grep LISTEN | grep -E "10250|10255"
# Watch live connections (verify socat forwarding)
while true; do netstat -an | grep 10250 | grep ESTABLISHED; sleep 1; done
# Check k3s-agent
limactl shell lima -- sudo systemctl status k3s-agent
# Check flannel FDB on any NUC
bridge fdb show dev flannel.1
Troubleshooting¶
Node NotReady after reboot¶
limactl list
# If Broken/Stopped:
limactl stop lima --force
limactl start lima
limactl shell lima -- sudo systemctl status k3s-agent
limactl shell lima -- sudo journalctl -u k3s-agent -n 20 --no-pager
Metrics showing unknown¶
# Is socat running and port open?
nc -zv <MAC_MINI_IP> 10250
# Is kubelet listening inside VM?
limactl shell lima -- sudo ss -tlnp | grep 10250
# Check socat log
cat /tmp/k3s-socat.log
# Restart socat
launchctl unload ~/Library/LaunchAgents/io.socat.k3s.plist
launchctl load ~/Library/LaunchAgents/io.socat.k3s.plist
K3s agent crashing with label error¶
Service file was overwritten by K3s reinstall:
limactl shell lima -- sudo chattr -i /etc/systemd/system/k3s-agent.service
# rewrite service file (see Step 6)
limactl shell lima -- sudo chattr +i /etc/systemd/system/k3s-agent.service
limactl shell lima -- sudo systemctl daemon-reload
limactl shell lima -- sudo pkill -9 containerd-shim
limactl shell lima -- sudo systemctl start k3s-agent
Flannel public-ip wrong (showing )¶
# Check lima0 has the /32 alias
limactl shell lima -- ip addr show lima0 | grep 172.25
# If missing, re-add it
limactl shell lima -- sudo ip addr add <MAC_MINI_IP>/32 dev lima0
# Restart k3s-agent to re-register
limactl shell lima -- sudo systemctl restart k3s-agent
# Verify
kubectl get node mac-mini -o jsonpath='{.metadata.annotations}' | python3 -m json.tool | grep public-ip
Pod-to-pod networking broken¶
# Check NUC FDB has correct IP for mac-mini
bridge fdb show dev flannel.1
# mac-mini entry should show dst <MAC_MINI_IP> not <LIMA_VM_IP>
# If wrong, clear and let flannel re-learn
sudo bridge fdb del <MAC_MINI_FLANNEL_MAC> dev flannel.1
# repeat on all NUC nodes
# Restart k3s-agent on mac-mini to re-announce
limactl shell lima -- sudo systemctl restart k3s-agent
Node NotReady — Mac Mini went to sleep¶
Symptoms:
Conditions: Ready = Unknown
Message: Kubelet stopped posting node status
Taints: node.kubernetes.io/unreachable:NoSchedule
node.kubernetes.io/unreachable:NoExecute
# Check if Mac Mini is reachable
ping -c 2 <MAC_MINI_IP>
# SSH in and restart k3s-agent
ssh non@<MAC_MINI_IP> "limactl shell lima -- sudo systemctl restart k3s-agent"
sleep 30 && kubectl get nodes
# Permanently fix — disable sleep
ssh non@<MAC_MINI_IP> "sudo pmset -a sleep 0 && sudo pmset -a disksleep 0 && sudo pmset -a displaysleep 0 && sudo pmset -a powernap 0"
Stale node entries after reinstall¶
kubectl delete node mac-mini
kubectl delete node lima-lima # if it appears
limactl shell lima -- sudo systemctl restart k3s-agent
sleep 20 && kubectl get nodes
ExternalIP still showing after removing node-external-ip¶
# Force re-registration
kubectl delete node mac-mini
limactl shell lima -- sudo systemctl restart k3s-agent
sleep 30 && kubectl get nodes -o wide
Longhorn manager CrashLoopBackOff¶
Symptom:
Fix — install open-iscsi inside Lima VM:
limactl shell lima -- sudo apt-get install -y open-iscsi
limactl shell lima -- sudo systemctl enable iscsid
limactl shell lima -- sudo systemctl start iscsid
kubectl delete pod -n longhorn-system -l app=longhorn-manager \
--field-selector spec.nodeName=mac-mini
kubectl get pods -n longhorn-system | grep mac-mini
Longhorn volume stuck degraded¶
Symptom:
This happens because Longhorn replica ports 10000-10999 are not forwarded by socat — replica rebuild fails.
Fix:
# 1. Disable replica scheduling on mac-mini
kubectl patch node.longhorn.io mac-mini -n longhorn-system \
--type=merge \
-p '{"spec":{"allowScheduling":false}}'
# 2. Delete mac-mini replicas
kubectl get replicas -n longhorn-system | grep mac-mini
kubectl delete replica <replica-name> -n longhorn-system
# 3. If volume attachment stuck with finalizer
kubectl get volumeattachment | grep <pvc-id>
kubectl patch volumeattachment <name> \
-p '{"metadata":{"finalizers":[]}}' \
--type=merge
# 4. Force pod to reschedule on NUC
kubectl delete pod <pod-name> -n <namespace> --force --grace-period=0
# 5. Watch recovery
watch kubectl get volume <volume-name> -n longhorn-system
Architecture Decision Summary¶
| Decision | Reason |
|---|---|
| Lima vzNAT not bridged | macOS requires Apple's com.apple.vm.networking entitlement for bridged mode — only Apple-signed binaries have it |
| socat not pf/pfctl | macOS pf rdr cannot redirect traffic to host's own IP (kernel limitation) — socat works at application layer |
/32 not /24 on lima0 |
/24 breaks default NAT route by routing all of <HOME_LAN_CIDR> through lima0. /32 is host-only, NAT unaffected |
| Same IP on en0 and lima0 | en0 <MAC_MINI_IP> = ARP + NAT ownership. lima0 <MAC_MINI_IP>/32 = kubelet validation. No conflict — lima0 never sends ARP |
| Immutable service file | K3s reinstall regenerates service file with original flags. chattr +i prevents this permanently |
| config.yaml before install | K3s reads config.yaml during install. Setting node-ip first ensures correct registration from the start |
| No node-external-ip | Redundant when InternalIP is already correct. Only needed when InternalIP was wrong ( |
| FDB not broadcast | Flannel uses Kubernetes API watch — event-driven, instant, scales to thousands of nodes |
Minimal Requirements Summary¶
REQUIRED:
en0 <MAC_MINI_IP> ← LAN visibility (ARP response + NAT ownership)
lima0 <MAC_MINI_IP>/32 ← kubelet validation only
config.yaml ← correct node-ip registration
socat ← bridge NAT gap between LAN and Lima VM
immutable svc ← prevent K3s overwriting service file
NOT NEEDED:
node-external-ip ← redundant when InternalIP is correct
IP alias plist ← redundant when <MAC_MINI_IP> is primary en0 IP
pf/pfctl rules ← doesn't work for own-IP traffic on macOS
bridged network ← blocked by Apple entitlement requirement
ROOT CAUSE OF ALL COMPLEXITY:
Lima VM IP (<LIMA_VM_IP>) ≠ LAN IP (<MAC_MINI_IP>)
Everything above exists to bridge this single gap