Every request but the probes needs a bearer token: there is no anonymous mode. OAuth client registration is by CIMD; dynamic registration refuses every request. See registration, consent, egress and TLS configuration.
VM provisioning service for the Giant Swarm Agent Platform: the write surface for virtual machines, the sibling of agent-manager (agents) and model-manager (models) next to the planned cluster-manager, which will hand the VMs it creates to Cluster API. It runs on a KVM host (a laptop, a bare-metal node, a CI runner) and turns it into a small cloud region: every VM gets an instance metadata service, a vTPM with measured boot, an immutable OS image, a Kubernetes node stack as a versioned layer, and attestation before it receives its bootstrap secrets. On the Agent Platform it runs as a pod of the KVM node.
The whole guest and host flow is built from systemd primitives rather than a
cloud-init-style agent. The image comes from mkosi (Arch Linux, systemd 261, a UKI with
signed expected PCR 11 values, an erofs root under signed dm-verity); the first boot runs
systemd-sysinstall onto a volume from the systemd storage provider; identity arrives as
system credentials and through systemd-imdsd from the IMDS; user-data is applied by
Ignition in the initrd; Kubernetes is a systemd-sysext pulled with systemd-sysupdate
and measured into PCR 13; /etc persists through an overlay on the var partition;
readiness is READY=1 over vsock, and the guest reports back with systemd-report. The
kernel runs only code from the image's signed dm-verity volumes: an IPE policy, locked for
the boot, against the image certificate vm-manager enrolls into each VM's UEFI db. Until
container images arrive as signed dm-verity layers, a node runs no container. The
only Giant Swarm binary in the guest, vm-agent, does one thing: quote the TPM. A VM
built this way behaves like an AWS or GCP instance from CAPI's point of view, on hardware
you own, without a hypervisor management plane in between.
The same operations are exposed twice from one process:
- REST/JSON under
/api/v1for the portal backend and scripts. Contract inapi/openapi.yaml, also served at/api/v1/openapi.yaml. - MCP (streamable HTTP,
/mcp) for muster and agents: toolsget_info,get_host,list_images,get_image,list_networks,get_network,list_vms,get_vm,get_vm_console,get_vm_metrics,get_vm_attestation,create_network,delete_network,create_vm,start_vm,stop_vm,reboot_vm,delete_vm,exec_vm,forward_port(through muster:x_vm-manager_<tool>). Every description says what to call first; the read-only, destructive, idempotent and open-world annotations, set on every tool, say whether it writes; and the server's instructions tell a model the call order (get_hostfirst, then images and a network, thencreate_vm).
Both surfaces call the same service and return the same JSON. On the platform vm-manager
is a pod, like its siblings: the Helm chart runs it privileged on
a KVM node with /dev/kvm and /dev/vhost-vsock from the node, QEMU and swtpm as its
children, the image directory mounted from a claim or a node path, OAuth against the
platform identity, and registers it with muster through its own MCPServer CR carrying
the agent-platform.giantswarm.io/tool-group: agent-platform label. The
agent-platform meta chart installs it as
components.vm-manager; agentlab runs that
component on a local kind cluster with a build from this checkout and proves the chain
headlessly (agentlab vm-manager-test), see
docs/development.md.
Design decisions and their reasons are in docs/design.md, the plan in
docs/plan.md, the install on a host or a cluster in
docs/install.md, development in docs/development.md.
| Operation | REST | MCP tool | Writes |
|---|---|---|---|
| This server's build (release version, commit, build time) and the names of its tools | — | get_info |
no |
Host capabilities: kernel, CPUs, memory, /dev/kvm, /dev/vhost-vsock, qemu / swtpm / systemd versions, OVMF image and its build, storage providers, ready + missing |
GET /api/v1/host |
get_host |
no |
| List the bootable images (id, version, UKI, disk, Kubernetes sysext versions, PCR policy) | GET /api/v1/images |
list_images |
no |
Describe one image (<id>_<version> or bare id = newest) |
GET /api/v1/images/{ref} |
get_image |
no |
| List the virtual networks with gateway and leases | GET /api/v1/networks |
list_networks |
no |
| Describe one network | GET /api/v1/networks/{name} |
get_network |
no |
| List every VM record, oldest first | GET /api/v1/vms |
list_vms |
no |
| Fetch one VM: state, IP, attestation, last error | GET /api/v1/vms/{id} |
get_vm |
no |
Tail of the serial console (lines, default 100) |
GET /api/v1/vms/{id}/console?lines= |
get_vm_console |
no |
Per-VM metrics: host (state, attestation, QEMU cpu_seconds and memory_rss_bytes, disk_bytes, install_seconds, boot_to_ready_seconds, the network's byte counters) and guest (summary of the last systemd-report upload, null until one arrived) |
GET /api/v1/vms/{id}/metrics |
get_vm_metrics |
no |
The guest's last systemd-report upload in full (REST only: too large for a tool result) |
GET /api/v1/vms/{id}/report |
— | no |
| The current boot's attestation verdicts | GET /api/v1/vms/{id}/attestation |
get_vm_attestation |
no |
Create a network (name, cidr, dns_search_domain); IMDS always on |
POST /api/v1/networks |
create_network |
yes |
Delete a network; conflict while a VM is attached |
DELETE /api/v1/networks/{name} |
delete_network |
yes, destructive |
Create a VM (name, image, kubernetes_version, cni_version, cpus 2, memory_mib 2048, disk_gib 20, network default, user_data (not on the default network), hostname, metadata, layer_certificates, wait_for ready) |
POST /api/v1/vms |
create_vm |
yes |
| Boot a stopped or failed VM from its disk | POST /api/v1/vms/{id}/start |
start_vm |
yes |
Power a VM down (ACPI, then SIGTERM/SIGKILL after --stop-timeout) |
POST /api/v1/vms/{id}/stop |
stop_vm |
yes |
| Stop, then start | POST /api/v1/vms/{id}/reboot |
reboot_vm |
yes |
| Stop if running, remove disk, vTPM state, lease, forwards and record | DELETE /api/v1/vms/{id} |
delete_vm |
yes, destructive |
Run a command as root in the guest over ssh on its vsock (command array; non-zero exit is a result) |
POST /api/v1/vms/{id}/exec |
exec_vm |
yes, destructive |
Expose a guest TCP port on a host loopback address (port) |
POST /api/v1/vms/{id}/forward |
forward_port |
yes |
| Prometheus exposition (a token, see Metrics); health, without a token | GET /metrics; GET /healthz, GET /readyz |
— | no |
Request bodies use the tool argument names (snake_case); resources come back as the
service records them (camelCase). Errors are {"error":{"code","message"}} with a stable
code, and MCP tool errors carry the same code: not_found, invalid_request, conflict,
unsupported, timeout (504: a wait_for milestone was not reached; the VM keeps
running), vm_failed (the VM failed before the milestone; lastError and the console say
why), internal_error.
docs/tools.md lists every MCP tool's description and input schema as a model
reads them (make tools-doc regenerates it).
A VM needs a network: create_network, or the network named default that serve
creates at startup from --network-subnet. create_vm allocates a disk on the storage
provider, a vTPM, a lease (MAC and IP are fixed for the VM's life) and a vsock id, then
runs two boots:
| State | What happens |
|---|---|
creating |
resources allocated, nothing running yet |
installing |
installer boot: QEMU boots the image's UKI directly (-kernel) with the image attached read-only and the blank target disk; vm-sysinstall.service runs systemd-sysinstall onto the target and reboots; QEMU runs with -no-reboot, its exit ends the phase. About 12 s. |
booting |
installed boot: OVMF, systemd-boot, the UKI from the target's ESP. Every later boot (start_vm, reboot_vm, a reboot from inside the guest) is this phase, each a new QEMU process. |
attesting |
the guest fetched its first nonce |
ready |
the boot's ready-stage quote verified and the guest's service manager sent READY=1 over vsock: 11 to 15 s after the installed boot starts for the bare image, longer when user-data runs kubeadm, which READY=1 waits for |
running |
the boot attested but READY=1 did not arrive within --boot-timeout; lastError says so, a late READY=1 still moves it to ready |
stopping, stopped |
stop_vm: ACPI power-down, SIGTERM and SIGKILL after --stop-timeout; a guest that powers itself off also lands in stopped. The disk stays, start_vm boots it again. |
failed |
the installer exited non-zero or hit --install-timeout (the console tail is in lastError), the installed boot's process died, or vm-manager killed a boot that failed its attestation (a rejected quote, READY=1 or --boot-timeout without a verified ready-stage quote; the reason is in lastError); start_vm boots an installed disk again, judged anew, delete_vm cleans up |
deleting |
delete_vm: stop if running, remove disk, vTPM state, lease, port forwards and record |
wait_for picks how long create_vm blocks: none returns at once and get_vm follows
the progress; installed, attested or ready block for that milestone, bounded by
--install-timeout (5 m) and --boot-timeout (4 m). Inside the guest, an installed boot
does the following in order:
- Firmware and boot loader. vm-manager's own OVMF (
firmware/README.md), with SMM and the image's certificate enrolled as PK, KEK and db, runs only the signed systemd-boot and UKI; it measures itself, the option ROMs and the SMBIOS tables; systemd-boot and the UKI are measured into PCR 4, the UKI's sections and phase transitions into PCR 11, the command-line addition into PCR 12. - Credentials. vm-manager passes
firstboot.hostname,ssh.authorized_keys.root,system.machine_idandvmm.notify_socketas SMBIOS type 11 credentials on every boot; the installer seals none onto the ESP. SMBIOS type 1 carriesmanufacturer=GiantSwarm, which the image's hwdb record keys the IMDS on. - IMDS in the initrd.
systemd-imds-early-network.servicebrings up DHCP on the virtual network,systemd-imds-import.serviceturns/hostnameand/public-keys/0into credentials. - Persistent state. The verity root is set up from
roothash=;persistent-etc.servicemounts the var partition, an overlay for/etcwith its upper directory on var, and/rootand/optas bind mounts from var, beforeinitrd-root-fs.target. The root stays the read-only erofs. - Attestation, initrd stage.
vm-agent attest --stage=initrdposts a quote of PCRs 0-7, 11 (phase pathenter-initrd), 12 and 13 with both event logs. A verified quote releases/user-data; until then it answers 503. - Ignition (first installed boot only: vm-manager adds
ignition.firstbootthrough the stub'skernel-cmdline-extraSMBIOS string) fetches/user-dataand applies CAPI's files and units to/sysroot; files below/etc,/var,/rootand/optland on the var partition. A VM without user-data gets 204 and the stages finish with nothing to do. - Switch root.
systemd-firstbootapplies hostname and friends once (the overlay keeps them), sshd comes up withsystemd-ssh-generator's AF_VSOCK listener and the per-VM keyexec_vmuses, networkd on the virtio NIC. - Kubernetes and CNI sysexts.
vm-kubernetes.servicereads/kubernetes-versionand/cni-versionfrom the IMDS, pullskubernetes_<kv>.rawwithsystemd-sysupdate --component=kubernetes(2 s for the 206 MB, a no-op on later boots) andcni_<cni>-<release>.rawwith--component=cni, merges both withsystemd-sysext refresh, extends PCR 13 with each file'sSHA256SUMSline, re-applies the extension's modules and sysctls and waits for containerd. A VM without a Kubernetes version skips it. - User-data's units. CAPI's kubeadm unit, ordered
After=vm-kubernetes.service, runskubeadm init|join. - Attestation, ready stage.
vm-agent attest --stage=readyquotes PCRs 0-7, 11, 12, 13 and 15 once the phase path isenter-initrd:leave-initrd:sysinit:ready; recorded forget_vm_attestation. A verified ready quote tells vm-manager that the boot is past Ignition: it drops the user-data from memory and from the state directory (userDataConsumedAton the VM), and/user-dataanswers 410 for the rest of the VM's life, so nothing that runs on the node later, pods included, can read it. - READY. PID 1 sends
READY=1over vsock when the boot transaction is complete, so with user-datareadymeanskubeadmsucceeded; it consumes the user-data as well when no verified ready quote did.vm-report-upload.timerpostssystemd-report uploadto the IMDS every 15 s from then on.
Attestation and the user-data gate reset on every installed boot, so start_vm and
reboot_vm attest again (the user-data itself is gone after the first boot, which no
later boot needs: none of them runs Ignition), as does a reboot from inside the guest: QEMU runs with
-no-reboot, ends on it, and vm-manager starts the next boot as a new process, so that the
firmware starts from a variable store vm-manager wrote. A reboot to ready takes 11 s; what user-data and
firstboot wrote survives it, as do the machine ID and the ssh host key. vm-manager does not
reattach to QEMU across its own restarts: on shutdown every VM is stopped gracefully, on
startup such VMs are stopped with a note in lastError.
images/ is a mkosi 27 project that builds, unprivileged, the base
image and the Kubernetes sysext. Everything vm-manager needs from a build is one directory,
the contract of --image-dir:
| Path | Content |
|---|---|
giantswarm-vm-base_<v>.efi |
the UKI: kernel, initrd (systemd-networkd, systemd-imdsd, vm-agent, Ignition), command line with roothash=, .pcrsig / .pcrpkey for PCR 11 |
giantswarm-vm-base_<v>.raw |
the disk image: ESP with systemd-boot and the UKI, erofs root, verity hash and signature partitions |
policy.json |
pcr11 per phase path (computed with systemd-measure calculate by make -C images verify), sysexts (the sha256 of every Kubernetes and CNI sysext, from which PCR 13 is computed), golden.sha256 for PCRs 0, 2-4, 6, 7 and golden_firmware (the firmware build they belong to) once vm-manager image golden ran; a released guest image artifact carries them |
sysupdate/base/ |
the A/B OS update artifacts the image's /usr/lib/sysupdate.d/ transfers name, with SHA256SUMS and SHA256SUMS.gpg |
sysupdate/kubernetes/ |
kubernetes_<kv>.raw per Kubernetes version, SHA256SUMS, SHA256SUMS.gpg |
The catalog (internal/images) pairs .efi and .raw by stem, reads the Kubernetes
versions from sysupdate/kubernetes/SHA256SUMS, and serves both sysupdate/ trees to the
guests at http://169.254.169.254/giantswarm/v1/sysupdate/<component>/, unfiltered: the
manifests are signed at build time, so the guest selects its version explicitly from
/kubernetes-version rather than trusting a per-VM listing. list_images is what the
catalog found; create_vm defaults to the newest version of the newest image and to the
newest Kubernetes version it offers.
Inside the image (images/mkosi.images/base): the hwdb record that maps SMBIOS vendor
GiantSwarm to the IMDS URL and key names (generated from the Go key table,
internal/imds), repart.sysinstall.d with the target layout (ESP, root A / verity A /
signature A copied bit for bit, empty B slots for A/B updates, var for the rest of the
disk), the credential-gated vm-sysinstall.service, the sysupdate transfers for the OS
and the Kubernetes component, vm-kubernetes.service, both vm-agent-attest.service
units, the report timer, and the exitrd that lets systemd-shutdown unmount var cleanly
under the /etc and /usr overlays. The Kubernetes sysext
(images/mkosi.images/kubernetes) is an erofs /usr delta with kubeadm, kubelet, kubectl,
containerd, runc, crictl and the CNI plugins, signed with the verity certificate the base
trusts, its units started through Upholds= on multi-user.target because a layer merged
during boot cannot be enabled by presets. A CNI's plugins come from a CNI sysext
(cni_<cni>-<release>.raw, chosen per VM with cni_version, default the newest Cilium
release): containerd's bin_dirs is /usr/lib/cni alone, and the copy a CNI DaemonSet
still makes into /opt/cni/bin is ignored.
Keys are generated per build (make -C images keys, git-ignored images/keys/): the
verity certificate, the PCR signing key for the UKI, and the PGP key behind SHA256SUMS,
whose public half ships in the image as /etc/systemd/import-pubring.pgp. vm-manager only
serves signed artifacts and never holds a private key. PCR 11 values are reproducible from
the UKI; PCR 13 from the sysext's SHA256SUMS line; the firmware PCRs are recorded once
per image and firmware build by a reference boot, see below.
Container images for these guests carry a dm-verity signature per layer, since IPE lets
the guest run code only from signed dm-verity devices: vm-manager layers sign signs an
image's layers in its registry and vm-manager layers verify checks them as a node does
(docs/layer-signing.md).
The guest proves its integrity to vm-manager over the IMDS, twice per boot. POST /attest/challenge with {ak_pub} answers {credential_blob, encrypted_secret}: a 32-byte
nonce, valid for 5 minutes and one use, sealed for that attestation key under the VM's
endorsement key (TPM2_MakeCredential); POST /attest/quote carries {stage, nonce, ak_pub, quote, signature, pcrs: {sha256: {...}}, event_log, userspace_log}. The verifier
(internal/attest) judges every quote; nothing turns it off. It checks that the attestation
key is certified, the signature over the quote with it, the nonce, that the quoted PCR digest
matches the PCR values sent, and then the values:
| PCR | Compared against | Meaning |
|---|---|---|
| 11 | policy.json pcr11[<phase path>] |
the exact UKI (kernel, initrd, command line) and its boot phase |
| 0, 2, 3, 4, 6, 7 | policy.json golden.sha256 |
firmware code, option ROMs, boot loader and UKI, Secure Boot policy |
| 12 | replay of event_log (systemd-boot's and systemd-stub's events) and then userspace_log (the initrd's os-separator), every event bound to what it claims: a command line's digest is that of its UTF-16 text; archives of credentials or configuration extensions from the ESP, add-ons and UKI profiles are rejected; the command lines must be exactly the one vm-manager passed through io.systemd.stub.kernel-cmdline-extra (ignition.firstboot on a boot that runs Ignition) or none |
the kernel command line and the ESP: a loader entry's options (measured by systemd-boot even where Secure Boot makes the stub ignore them) or a credential added on the ESP fails the boot's attestation |
| 13 (initrd stage) | zero or the os-separator alone | nothing extended the initrd: an extension image added on the ESP fails the quote that releases user-data |
| 13 (ready stage) | computed from policy.json sysexts for the VM's Kubernetes and CNI versions, the os-separator alone for a VM without Kubernetes; never golden |
the exact Kubernetes and CNI sysexts, or none |
15 (ready stage; required when policy.json has "pcr15": "layer-certificates", which every image of this repository sets) |
replay of userspace_log, every record bound to its word (sha256 of a machine-id:, file-system: or layer-certificate: word, anything else rejected); its layer-certificate:<sha256> words against the VM's layer_certificates, in order |
the installation layer certificates the initrd enrolled, exactly those served |
| 1 | replay of event_log: the ACPI and SMBIOS tables QEMU builds from vm-manager's arguments and the SMBIOS structures systemd-boot and systemd-stub measure, which the guest cannot write, replayed; BootOrder and the Boot#### options, each bound to its data, against the VM's first verified boot (get_vm bootConfig) |
the firmware's boot configuration in the VM's variable store: an option root changes fails the next boot |
| 5 | replay of event_log: the GPT, bound to its event, holds the partitions of the image's installed disk and nothing else (the ESP, slots A and B of root, verity and verity signature, var: their types, labels, attributes and counts); systemd-boot's loader.conf against the VM's first verified boot; the separator and ExitBootServices |
the partition table and the boot loader's configuration: a partition added, retyped, relabelled or given another attribute, or an edited loader.conf, fails the next boot |
Every attestation key is certified against the VM's own endorsement key (EK), the first
quote of the VM's first boot included. vm-manager reads the EK from the VM's vTPM itself
before the VM's first QEMU starts (get_vm shows it as endorsementKey), and the guest
recovers a challenge's nonce only with TPM2_ActivateCredential in the vTPM that holds that
EK, with the attestation key loaded: a quote by a key of another TPM, another VM's included,
or by a key the nonce was not sealed for is rejected. The certified key of the first verified
initrd quote is pinned per VM, kept in the VM's record so a restarted vm-manager pins it
again; a later quote from a different key is rejected. Only
a verified initrd quote releases /user-data, for every VM; the ready stage is what makes
the boot ready. get_vm_attestation shows both verdicts, the PCRs quoted and whether
user-data was released.
A boot that fails its attestation is killed, not powered down, and the VM is failed
with the reason in lastError: a rejected quote of either stage, on any boot (e.g.
initrd attestation rejected: golden mismatch: pcr 0 expected ..., got ..., also on the
console from vm-agent-attest.service), READY=1 without a verified ready-stage quote of
the same boot (a boot that skipped the agent: a masked unit, a command line that turns it
off), and a boot without one by --boot-timeout. A rejected initrd quote ends the boot
before user-data is released. start_vm boots the VM again and judges that boot anew.
Caveats. PCR 1 and 5 have no golden values, because EDK2 measures the ACPI and SMBIOS
tables (sized for the VM, carrying vm-manager's per-VM credential strings) and the boot
entry with the ESP's partition GUID into PCR 1, and PCR 5 holds the installed disk's GPT;
the verifier replays the firmware event log against them instead. The boot variables and
loader.conf are compared with what the VM's first verified boot measured: before it,
only vm-manager's installer wrote them. The ESP is writable for root on a node, so the verifier judges what
the boot took from it: the command line and the archives in PCR 12, an extension image in
PCR 13 at the initrd stage; with Secure Boot on, a loader entry's command line does not take
effect either. The integrity story rests on PCRs 0, 4, 7 (Secure Boot with the image's keys),
11, 12 and 13, and on the verity signature and SHA256SUMS.gpg for the content itself.
Released golden values. The release pipeline records the golden values of every
release before it pushes and signs the guest image artifact (which vm-manager image pull, the pod's init container, refuses without that signature): the guest-image job of
.circleci/custom.yml runs hack/guest-image-golden.sh, which boots the release's guest
image on the release's container image as a pod of the release does, with its
vm-manager, QEMU, swtpm and OVMF (the firmware PCRs measure its OVMF code and variable
store and its virtio-net option ROM): vm-manager image golden boots a reference VM of the
image, records the PCRs of its ready quote, and boots a fresh VM that must verify against
them. A pod of a release therefore verifies both quotes of its first VM, and a release
that moves the firmware ships the values of the new build.
Golden values come from that recording only. A local build's policy.json has none, and
the verifier rejects every quote of it: record them the same way, vm-manager image golden <image> --image-dir <dir> on the host whose firmware the server boots, or
hack/guest-image-golden.sh <vm-manager image> <image dir> (make guest-image-golden)
for a container image. The reference boot is checked as every boot is but for the golden
comparison, gets no user-data, and runs in the command's own process: serve has no mode
that accepts a PCR without a golden value. A boot on other firmware is then refused;
e2e/attestation_test.go proves it with a distribution's OVMF build (golden mismatch on
PCR 0, the VM killed before user-data is released).
What invalidates golden values. They belong to one image and one firmware build. A new
image changes PCR 4 (boot loader and UKI), and PCR 13 with its Kubernetes sysext; a new
firmware build changes PCR 0, which measures the firmware, and PCR 7 when its variable
store template changes. Every VM boots the OVMF of the Giant Swarm EDK2 line, a
reproducible build with SMM, Secure Boot and TPM 2.0 that the Dockerfile pins by tag and
digest (firmware/README.md); the container image ships it under
/usr/share/vm-manager/firmware, and make firmware fetches the same files on a host. Its
PCR 0 is the same for every VM size and every boot of a VM. A new release of the line
arrives as a pull request and release note of its own (update OVMF firmware to <version>, re-record golden PCRs), whose release records the values for it, and no other release
changes it. get_host reports the build VMs boot with (firmware: the SHA-256 of
ovmfCode and the line's release its firmware.json names) and serve logs it at start,
with a warning per image whose golden_firmware names another build. Values recorded under
another build fail every quote with golden mismatch: pcr 0, and the verdict says which
build they were recorded for and which one boots; when the build is the recorded one, it
says so, and the boot itself differs.
Recording golden values again. In the pod the firmware changes only with a release of
vm-manager, whose guest image artifact carries the values for it. On a host install a
system update may replace the firmware package: run vm-manager image golden <image> there
again (as root next to a running server, with a --vm-uid-base apart from the server's)
and restart the server, which reads the policy at start.
Without a state claim the pod fetches the guest image at every start and forgets the values recorded into it; a released artifact brings its own values back each time.
Networks are rootless (internal/network, gvisor-tap-vsock): each is its own userspace
Ethernet switch with a gVisor TCP/IP stack as gateway, DHCP server, DNS forwarder and NAT,
so vm-manager needs no bridges, tap devices, iptables or CAP_NET_ADMIN and runs the same
way on a laptop and a CI runner. For a network a.b.c.0/24: .1 is the gateway, .2-.253
the pool (MAC and IP derived from each other, so a lease is static for the VM's life and
survives restarts through networks.json), .254 reserved, .255 broadcast. VMs on
different networks never see each other, even with overlapping CIDRs; a VM reaches whatever
the host reaches. Every VM has its own port on its network's switch, a socket only its QEMU
connects to, and every frame it sends must carry its lease: its MAC as the source, its
address as the IPv4 source and the ARP sender (0.0.0.0 only for DHCP and address probes).
The rest, IPv6 included, is dropped, a frame with another MAC or address than the lease's
counted in vm_manager_network_frames_dropped_total, so a VM
cannot take a peer's address or MAC, or poison another VM's or the gateway's ARP. A CNI
therefore encapsulates pod traffic between nodes (Cilium's default VXLAN, which
cilium-app keeps) or masquerades it: pod addresses routed natively on the network, and
virtual addresses announced over ARP (kube-vip, MetalLB L2), are dropped.
The IMDS lives at 169.254.169.254:80 as a virtual IP of the gateway, inside the stack,
exactly where a cloud guest expects it; the guest is identified by the port its connection
came through on the network the request arrived on and nothing else (no token flow,
X-Forwarded-For ignored, anything else gets 403). Every network's IMDS has its own handler
that knows that network's VMs only, so networks with overlapping CIDRs never answer for
each other's VMs. No guest
address leads to the host's 127.0.0.1, where vm-manager's own API listens: the last host
address of a network (.254 in a /24) is reserved, never leased and not answered. In the
other direction forward_port binds a 127.0.0.1:<port> on the host
and proxies it to the guest's port (6443 for kubectl); a forward lives until the VM is
deleted. exec_vm does not use the network: the guest's sshd listens on AF_VSOCK only, and
vm-manager dials it on the VM's vsock CID, which no other VM or pod can answer for. Expect hundreds
of Mbit/s, IPv4 only, no UDP or ICMP from the host into the network; a kernel tap/bridge
backend behind the same interface is a listed follow-up.
GET /metrics is the Prometheus exposition (--metrics-enabled, default on). It names
every VM, so it sits behind the same guard as the API, and no setting serves it without a
token: it accepts the OAuth tokens of Identity and the scrape token in
--metrics-token-file, a credential of the scraper's own (at least 32 bytes) that opens
/metrics and nothing else. The file is read on every scrape, so a rotated Secret takes
effect without a restart. The chart generates the token into the Secret
<fullname>-metrics and its ServiceMonitor presents it (authorization with that Secret).
Host side, per VM: vm_manager_vm_state{vm,name,state} (1/0), vm_manager_vm_attestation,
vm_manager_vm_info, vm_manager_vm_created_timestamp_seconds,
vm_manager_vm_install_seconds, vm_manager_vm_boot_to_ready_seconds (plus
_duration_seconds histograms), vm_manager_vm_cpu_seconds_total and
vm_manager_vm_memory_rss_bytes of the QEMU process, vm_manager_vm_disk_bytes; per
network vm_manager_network_bytes_total{network,direction},
vm_manager_network_frames_dropped_total{network} (frames a VM sent with another MAC or
address than its lease's, which port security drops) and vm_manager_network_leases; vm_manager_vms{state} and vm_manager_build_info.
Guest side, every entry of the guest's last systemd-report upload becomes a series:
io.systemd.Manager.UnitActiveState for systemd-networkd.service is
vm_guest_io_systemd_manager_unit_active_state_info{vm,object="systemd-networkd.service",value="active"} 1,
io.systemd.Manager.NRestarts is vm_guest_io_systemd_manager_nrestarts_total{vm,object},
the entry's fields are labels. Each upload replaces the previous one; an upload is at most
8 MiB (larger ones are refused and counted in vm_guest_reports_rejected_total{vm,reason}), at
most 1000 series are kept per VM (--metrics-guest-series-limit lowers it, nothing raises it),
the rest are counted in vm_guest_report_series_dropped_total{vm,reason}, and a guest cannot
write vm-manager's own series or another VM's vm label (docs/guest-metrics.md);
vm_guest_report_age_seconds says how stale a guest's data is. get_vm_metrics is the per-VM summary of both sides;
GET /api/v1/vms/{id}/report is the raw upload. internal/metrics documents the mapping
and the cardinality policy.
Traces go out over OTLP when OTEL_EXPORTER_OTLP_ENDPOINT is set (the chart's
observability.otel.endpoint); the standard OTEL_* variables configure the exporter and the
sampler. Spans: POST /mcp, mcp.<method> per JSON-RPC request (gen_ai.tool.name on
mcp.tools/call) and tool.<name> per tool handler.
The caller, not the host user. vm-manager is an OAuth 2.1 resource server
(mcp-oauth) in front of the MCP endpoint, the REST
API and /metrics, always: serve does not start without an identity provider, and no
flag, variable or chart value turns the guard off. Providers dex (with --dex-ca-file for a Dex with a private certificate; a Dex on a
private address and an egress proxy through HTTP_PROXY, HTTPS_PROXY and NO_PROXY need
no flag) and google. Nobody logs in to vm-manager
itself: muster forwards the session's IdP id_token byte-identical and the portal sends the
signed-in user's, both validated against the IdP's JWKS because their audience is in
--oauth-trusted-audiences, also when the issuer host's JWKS endpoint is private (a
jwks_uri on another host that resolves privately goes in --sso-allow-private-ip-jwks-hosts);
a token for none of the trusted audiences is refused with 401. Tokens from this server's
own OAuth flow work too; clients identify themselves by a client ID metadata document
(OAuth client registration), and dynamic registration
refuses every request: no initial access token is configured. The caller (internal/identity: subject, email, groups, source sso|oauth) is on
the request context and in the debug log of every authenticated request; VM records do not
carry it yet.
/healthz and /readyz, which answer ok and nothing else, and the OAuth endpoints
(metadata, authorize, token, callback) stay outside the guard. A lab or a test runs the same
way, against its own identity provider: the e2e suite and the release pipeline's golden
script use hack/testidp, a test OpenID provider whose id_tokens the server validates like
Dex's (development).
make build
./vm-manager serve --listen 0.0.0.0:8080 --oauth-base-url https://vmm.example \
--dex-issuer-url https://dex.example/dex --dex-client-id ... --dex-client-secret ... \
--oauth-trusted-audiences agent-platformEvery flag has an environment fallback named in vm-manager serve --help; flags win.
| Flag | Environment | Default | Meaning |
|---|---|---|---|
--listen |
VM_MANAGER_LISTEN |
127.0.0.1:8080 |
listen address |
--mcp-path |
VM_MANAGER_MCP_PATH |
/mcp |
MCP endpoint path |
--state-dir |
VM_MANAGER_STATE_DIR |
$XDG_STATE_HOME/vm-manager, else ~/.local/state/vm-manager, else /var/lib/vm-manager |
VM records, consoles, vTPM state, sockets; keep it short (unix socket paths) |
--image-dir |
VM_MANAGER_IMAGE_DIR |
<state-dir>/images |
the image directory of Images |
--network-subnet |
VM_MANAGER_NETWORK_SUBNET |
192.168.127.0/24 |
CIDR of the default network, created at startup when missing |
--default-network |
VM_MANAGER_DEFAULT_NETWORK |
default |
its name; create_vm attaches to it unless told otherwise, and refuses user_data on it: every caller's VMs share it, so a bootstrapped node goes on a network of its cluster's own |
--install-timeout |
VM_MANAGER_INSTALL_TIMEOUT |
5m |
installer boot ceiling, then failed |
--boot-timeout |
VM_MANAGER_BOOT_TIMEOUT |
4m |
ceiling of an installed boot: without a verified ready-stage quote by then it is killed and the VM failed, attested without READY=1 it is running; raise it when user-data runs kubeadm init with image pulls |
--stop-timeout |
VM_MANAGER_STOP_TIMEOUT |
30s |
graceful power-down before SIGKILL, also on shutdown |
--ovmf-code, --ovmf-vars |
VM_MANAGER_OVMF_CODE, VM_MANAGER_OVMF_VARS |
/usr/share/vm-manager/firmware/OVMF_CODE.fd, OVMF_VARS.fd |
code image and variable store template (copied per VM) of vm-manager's own firmware (firmware/README.md; make firmware fetches it into firmware/build). Every VM boots it with SMM and Secure Boot, the image certificate enrolled as PK, KEK and db |
--notify-port |
VM_MANAGER_NOTIFY_PORT |
0 (kernel picks) |
vsock port for the guests' READY=1 |
--metrics-enabled, --metrics-guest-series-limit, --metrics-token-file |
VM_MANAGER_METRICS_ENABLED, VM_MANAGER_METRICS_GUEST_SERIES_LIMIT, VM_MANAGER_METRICS_TOKEN_FILE |
true, 1000 (also the maximum), — |
see Metrics |
--oauth-base-url, --oauth-provider, --oauth-trusted-audiences, --sso-allow-private-ip-jwks-hosts |
VM_MANAGER_OAUTH_BASE_URL, VM_MANAGER_OAUTH_PROVIDER, OAUTH_TRUSTED_AUDIENCES, SSO_ALLOW_PRIVATE_IP_JWKS_HOSTS |
required, dex, —, — |
see Identity |
--dex-issuer-url, --dex-client-id, --dex-client-secret, --dex-ca-file |
DEX_ISSUER_URL, DEX_CLIENT_ID, DEX_CLIENT_SECRET, DEX_CA_FILE |
— | the Dex provider; the first three are required with it |
--google-client-id, --google-client-secret |
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET |
— | the Google provider |
--launcher |
VM_MANAGER_LAUNCHER |
auto |
systemd (transient services under the user or system manager), process (plain children), or auto |
--detach-vms-on-exit |
VM_MANAGER_DETACH_VMS_ON_EXIT |
true |
with the systemd launcher, leave VMs running on shutdown and reattach on the next start |
VMs survive vm-manager restarts. QEMU and swtpm run as transient systemd
services (vm-manager-<id>-qemu, vm-manager-<id>-swtpm, grouped in
vm-manager.slice) under the user's service manager when vm-manager is
unprivileged and under the system manager when it is root; on shutdown the
VMs are left running (--detach-vms-on-exit, default on) and the next
serve on the same --state-dir reattaches to them, exit status included.
The state dir is the contract: vms/<id>/vm.json names the units and PIDs,
and the sockets, console and logs below it are where the running processes
expect them, so do not move it while VMs run. vm-manager's own systemd unit
needs no cgroup delegation; without a reachable service manager (--launcher process, or no $XDG_RUNTIME_DIR/systemd for an unprivileged run) the VMs
are plain child processes and end with vm-manager, which logs a warning.
The state directory holds networks.json, networks/<name>/<n>.sock (a VM's port, n the host number of its address), one vms/<id>/
per VM (vm.json, console.log, user-data, ssh_key and the pinned ssh_host_key,
ovmf_vars.fd, tpm/, swtpm.log, run/qmp.sock, report.json), volumes/ when no systemd storage
provider is present, and by default images/. Startup order: storage detection (the
fs provider's socket under /run/systemd/io.systemd.StorageProvider/, else files),
networks restored with their leases, the vsock notify listener, the image catalog, the
VM records (VMs that were running become stopped), then the default network.
Host prerequisites of create_vm: KVM (/dev/kvm), vhost_vsock (/dev/vhost-vsock),
qemu-system-x86_64, swtpm and an OVMF build. systemd (the transient units VMs
survive restarts in) and systemd 261's storage provider (provider volumes instead of
files) are capabilities the report names but does not require: without them VMs are
child processes and volumes plain files — the shape of vm-manager in a pod. No root on a
host: the daemon needs group access to the two devices and nothing else.
GET /api/v1/host reports ready and missing so a client can show what to install. vm-manager image golden is the second
command (see Attestation); vm-manager version the third.
As a system service: deploy/systemd/vm-manager.service
runs serve --state-dir=/var/lib/vm-manager --image-dir=/var/lib/vm-manager/images --listen=127.0.0.1:8080 as the vm-manager user
(sysusers.d/vm-manager.conf) with
SupplementaryGroups=kvm, DeviceAllow= for /dev/kvm, /dev/vhost-vsock and
/dev/net/tun, StateDirectory= and RuntimeDirectory=, hardening that leaves QEMU,
swtpm and unix sockets working, EnvironmentFile=-/etc/vm-manager/env for every other
flag, and Restart=on-failure. Stopping the service stops the VMs on it.
docs/install.md walks through packages, device permissions, images,
the first VM, logs and upgrades.
As a pod: the chart (the image gsoci.azurecr.io/giantswarm/vm-manager
with QEMU, swtpm and Ubuntu's OVMF; the chart in the giantswarm catalog,
oci://gsoci.azurecr.io/charts/giantswarm/vm-manager; both released by the generated
CircleCI pipeline on every tag) runs serve --launcher process unprivileged — /dev/kvm
and /dev/vhost-vsock from vm-manager's own kubelet device plugin (vm-manager device-plugin, a DaemonSet of the chart), seven capabilities, vm-manager's own seccomp
filter (the runtime's default set plus AF_VSOCK), nothing mounted from the node; QEMU
and swtpm of each VM run as a user of their own, without capabilities, QEMU under its
-sandbox — with the state directory on an emptyDir or a claim
(persistence), the guest image fetched into it at pod start by an init container from
the OCI artifact every release publishes (guestImage,
gsoci.azurecr.io/giantswarm/vm-manager-guest-image:<version>; vm-manager image pull /
image push), OAuth from the platform's global.identity, and the muster MCPServer CR
(muster.mcpServer.enabled). A pod restart ends the VMs (their records and disks survive
on a claim); the guests' traffic leaves through the pod's own network. The agent-platform
meta chart installs it as components.vm-manager, off by default: KVM nodes are not
universal.
See docs/development.md: make test, make lint,
make test-integration (real QEMU, OVMF, swtpm, the storage provider), make agent,
make image / make -C images and make image-verify, make e2e (seven boot tests on
KVM with the built image, about 6 min, 45 m ceiling), the package layout, the local loop
with image golden recording the golden values of a local build, debugging recipes and the "Adding a tool"
checklist.
Prototype. Waves 1 to 3 of docs/plan.md are on main and proven by the
e2e suite on the development host: install 12 s, installed boot to READY=1 11-15 s,
reboot to ready 11 s, Kubernetes sysext pull 2 s, a CAPI-shaped control plane Ready 85 s
after create_vm, a worker joined 46 s after its own, attestation record / golden / tamper
in 111 s. Wave 4 is in progress: CI with the image build and a KVM e2e job, these docs,
VMs as transient systemd units so that they survive vm-manager restarts, and
multi-version publishing of the Kubernetes sysext directory.
Follow-ups outside the prototype, in the order they are likely to matter: the CAPI
infrastructure provider or cluster-manager glue that maps Machines to create_vm; a
tap/bridge network backend; the host-side pre-install fast path
(systemd-repart from the same definitions, skipping the installer boot); a multi
control plane endpoint (kube-vip on a reserved network address).