在 Kubernetes 上运行原生 macOS 工作负载
Run native macOS virtual machines as Kubernetes pods.
macOS-vz-kubelet is a Virtual Kubelet provider that
turns an Apple Silicon Mac into a Kubernetes node. Each pod's first container boots as a native macOS VM on
Apple's Virtualization framework; optional Docker
side-car containers run in the same pod for logging, monitoring, or artifact handling.
It targets teams scaling macOS CI/CD (GitLab runners, build and test farms) on a cluster, at near-native Apple Silicon performance and without QEMU/KVM.
Running macOS under Kubernetes traditionally means QEMU/KVM on Linux, which cannot fully use Apple Silicon
hardware. macOS-vz-kubelet instead runs VMs natively through Virtualization.framework on the Mac itself, so
guests run at near-native speed.
The project is designed to:
For exactly what is and is not supported, see the Feature overview.
The kubelet runs on the Mac host as a Virtual Kubelet provider and orchestrates two backends from one pod spec.
Typical flow:
darwin/arm64 only.kubectl exec/attach into the VM, the readiness probe, postStart hooks,
and stats all run over SSH.Tooling versions are pinned in .mise.toml (Go, goreleaser, Ruby). Builds run on macOS and produce a
MacOSVK.app bundle.
make snapshot # local development build
make release # signed release build (set RELEASE_CERTIFICATE_NAME, RELEASE_PROVISION_PROFILE_PATH)The binary needs Virtualization.framework entitlements. To ad-hoc sign a locally built binary:
codesign --entitlements resources/vz.entitlements -s - Bridged networking requires the additional vmnet entitlements in resources/release.entitlements, which need
Apple approval. See Networking.
Create a base VM image. Use a Virtualization.framework-compatible tool such as macosvm.
Package and push it in the custom OCI format with oras-macos-vz:
oras-macos-vz push -hWrite a pod manifest that references the OCI image. See Examples.
Run the pod. The kubelet picks it up, pulls the image, and boots the VM. Status is reported back as for a regular container.
Interact with kubectl exec (and attach) into the VM or any side-car container.
Configure the kubelet with the flags and environment variables below.
Networking runs in one of two modes.
kubectl exec/attach reach the VM over SSH on its local IP. The VM IP is discovered from the host ARP
table.Enable bridged mode by setting VZ_BRIDGE_INTERFACE to the host interface name. Bridged mode requires the
VMNet and VM Networking capabilities, which need Apple approval; see this
Apple Developer Forums thread for how to request them.
After approval, generate a Mac Development certificate, an App ID with those capabilities, and a provisioning
profile, then build a release binary signed with resources/release.entitlements.
VM images use a custom, OCI-compliant format. See the OCI manifest example.
macOS images are large (tens of gigabytes with Xcode and simulators preinstalled). The packaging step compresses image layers (parallel gzip) so they store and transfer at a fraction of the raw size, and the kubelet decompresses on pull.
A host runs at most two VMs at once (MaxVirtualMachines, enforced by a semaphore; a third pod waits for a
free slot). This reflects a Virtualization.framework limit. To let concurrent VMs share one base image while
keeping independent state, each pod gets a copy-on-write
clone of the disk and auxiliary storage.
Overlays are removed when the VM stops; the base image is never mutated.
Local image files carry a recorded digest to guarantee integrity:
The tables below list supported Kubernetes features. Anything not listed is unsupported.
| Feature | Supported | Comments |
|---|---|---|
| Node addresses | ✅ | |
| Node capacity | ✅ | |
| Node daemon endpoints | ✅ | |
| Operating system | ✅ | Darwin macOS only |
| Feature | Supported | Comments |
|---|---|---|
| Create and delete pods | ✅ | |
| Update pods | ❌ | Recreate the pod instead. |
| Get pod, pods, and pod status | ✅ | |
| Security policies | ❌ | |
| Init containers | ❌ | On the short list. |
| Regular containers | ✅ | Container 0 must be the macOS VM; every later container runs on the Docker daemon. |
| Feature | Supported | Comments |
|---|---|---|
| Container logs | ⚠️ | Docker side-cars only. |
| Container exec | ✅ | VM exec needs VZ_SSH_USER plus one of VZ_SSH_PRIVATE_KEY_BASE64 / VZ_SSH_PRIVATE_KEY_PATH / VZ_SSH_PASSWORD. Side-car exec works by default. |
| Container attach | ✅ | Docker attach; macOS VM via an interactive SSH shell. |
| Container metrics | ✅ | Both backends: macOS VM (CPU and memory) and Docker side-cars. |
| Resource requests | ⚠️ | Size the macOS VM. Docker containers ignore them. |
| Resource limits | ❌ | Ignored; VMs are fixed-size. |
| Liveness / readiness / startup probes | ❌ | Pod-spec probes are not evaluated. See the readiness note below. |
| Lifecycle hooks (postStart, preStop) | ⚠️ | Exec-shaped hooks only. A successful postStart hook gates pod Ready; preStop runs within the grace period. |
Readiness gating. Pod-spec probes are not evaluated, but every macOS pod is held NotReady until an internal
SSH readiness check succeeds (the guest sshd must answer), bounded by VZ_SSH_READINESS_TIMEOUT. If a pod
defines an exec postStart hook, Ready is gated on that hook finishing successfully (bounded by
VZ_POSTSTART_TIMEOUT); a permanently unreachable VM fails the pod rather than hanging.
| Feature | Supported | Comments |
|---|---|---|
| Host volumes | ✅ | |
| Empty dir volumes | ✅ | sizeLimit is not enforced. |
| Per |
暂无开放 Issues,或尚未同步最近议题。