Skip to content

Latest commit

 

History

History
547 lines (507 loc) · 43.8 KB

design.md

File metadata and controls

547 lines (507 loc) · 43.8 KB

vm-manager design

Status: prototype design, decided in a grill session on 2026-09-12 and brought in line with main after wave 3 (the same day): open points that were closed carry an Implemented note, statements that no longer matched the code were corrected. This document is the source of truth for architecture decisions; the roadmap and agent plan live in plan.md, the user-facing description in the README.

What it is

vm-manager is a Go MCP + REST server, a sibling of agent-manager, model-manager and the planned cluster-manager. It provisions virtual machines on a KVM host that behave like cloud-provider VMs: an instance metadata service (IMDS), a vTPM with measured boot, an immutable and composable OS image, fast boot, and Kubernetes prerequisites. Agents on the Giant Swarm agent platform create VMs through vm-manager and hand them to the CAPI based cluster-manager to bootstrap workload clusters.

Everything is systemd-native: images are built with mkosi, installed with systemd-sysinstall onto volumes from the systemd storage provider, configured with systemd-firstboot and system credentials, fed metadata by systemd-imdsd, layered with systemd-sysext delivered by systemd-sysupdate, measured with systemd-measure (PCR 11) and systemd-pcrextend (PCR 13), and observed through the guest's systemd-report uploads.

Decisions

Topic Decision Why
VM backend QEMU/KVM driven directly by vm-manager on a Linux host; runtime behind a Go interface Full control over SMBIOS, vTPM, vsock, netdev; vmspawn/KubeVirt can be added later
Bootstrap contract Cloud-like IMDS user-data through a Giant Swarm IMDS provider Exactly how AWS/GCP feed CAPI's kubeadm bootstrap output
Base OS Arch Linux via mkosi (ParticleOS style: UKI, verity, sysupdate) Host parity (systemd 261), fastest build loop; swap by changing Distribution=
Provisioning Installer boot runs systemd-sysinstall onto a storage-provider volume, then reboots into systemd-firstboot Same flow later works for bare metal; credentials bound to the VM's own vTPM
Network Rootless userspace SDN via gvisor-tap-vsock embedded in vm-manager No root, runs on laptops and GitHub Actions; IMDS served inside the stack
Attestation swtpm vTPM + measured boot; vm-manager verifies a TPM quote and gates user-data The "shielded VM" story: only integrity-proven VMs get bootstrap secrets
Code integrity IPE: the kernel executes and loads code only from dm-verity volumes whose signature it verified (the root, the sysexts); vm-manager writes the image's certificate into each VM's UEFI db before every QEMU start (platform keyring), and a guest's reboot is a new QEMU; PID 1 and the kernel's usermode helpers lose CAP_MAC_ADMIN after the signed policy is loaded Immutable for real: root on the node can write to /var and /etc but runs nothing the image did not ship, and cannot switch the policy off. No container runs until images arrive as signed dm-verity layers (images/README.md)
Guest image signatures image pull always verifies the artifact before it writes anything. A released vm-manager accepts the release's cosign keyless signature alone. A local build is signed at push with a build key (image push --sign-key, an ECDSA P-256 key image keygen makes per machine) whose public key only a vm-manager built from source on that machine carries, compiled in with -ldflags -X (make); image trust prints what a binary trusts The artifact decides what every VM trusts and what attestation accepts, so no flag, value or environment variable may accept an unverified one, and no setting of a released chart may add a signer: trust follows the binary's provenance. A lab boots its own builds with a vm-manager from the same source. The release pipeline checks that its binary trusts no build key. Trusting a file or a value at runtime would be a way around the release signature on any installation
Pod privileges Unprivileged pod: /dev/kvm and /dev/vhost-vsock from vm-manager's own kubelet device plugin (vm-manager device-plugin, a DaemonSet of the chart, resource giantswarm.io/kvm); root with CHOWN, DAC_OVERRIDE, FOWNER, KILL, SETUID, SETGID and SETPCAP only; seccomp Unconfined with vm-manager's own filter, always installed (the runtime's default set plus AF_VSOCK; no switch turns it off, and vm-manager refuses to start without it) The device cgroup admits a host device only through the kubelet, and the runtime's default seccomp profile refuses the vsock sockets the guests' READY=1 and ssh need, so the pod gains vsock over RuntimeDefault and nothing else. CDI (node configuration per installation) and a security-profiles-operator profile (another component) were the alternatives
Kubernetes systemd-sysext layer pulled at boot as a systemd-sysupdate component One base image, N Kubernetes versions, measured into PCR 13
User-data executor Ignition in the mkosi initrd; cluster-manager sets KubeadmConfig format: ignition The standard first-boot provisioner for immutable images (Flatcar, FCOS); the guest agent only attests
CI GitHub Actions with KVM for image build + boot e2e; unit/lint everywhere Hosted runners expose /dev/kvm; no self-hosted infra to start
Repo github.com/giantswarm/vm-manager, public, team-bumblebee Consistent with siblings

Host architecture

                      MCP /mcp + REST /api/v1 + /metrics + /healthz
                                      |
                              internal/api, internal/server
                                      |
                                internal/vm (service, state machine, JSON state dir)
      +----------------+---------------+----------------+----------------+
      |                |               |                |                |
 runtime/qemu     network        imds            storage           attest
 (QEMU, swtpm,   (gvisor-tap-  (GiantSwarm      (io.systemd.      (quote verify,
  OVMF, QMP,      vsock L2,     provider,        StorageProvider   expected PCRs,
  vsock READY)    DHCP, NAT,    attest, report,  Varlink client)   user-data gate)
                  169.254.169.254) sysupdate dir)

Packages (sibling layering, see development.md "Layout"):

  • internal/vm: VM lifecycle state machine creating -> installing -> booting -> attesting -> ready with running (no READY=1 within the boot timeout), stopping, stopped, failed and deleting, persisted as one JSON file per VM under the state dir ($XDG_STATE_HOME/vm-manager, ~/.local/state/vm-manager or /var/lib/vm-manager). Each VM's QEMU and swtpm run as transient systemd services (internal/runtime/proc) so vm-manager restarts do not kill VMs: vm.json records their unit names and PIDs, Load reattaches, and QEMU reconnects its netdev with reconnect-ms.
  • internal/runtime/qemu: builds the QEMU command for phase A (installer) and phase B (installed), seeds the per-VM OVMF vars copy, talks QMP (status, powerdown, events), captures the serial console to a file, listens on AF_VSOCK for READY=1 from the guest (vmm.notify_socket credential). internal/tpm runs the per-VM swtpm process, internal/runtime/proc supervises both. Every QEMU runs under its own seccomp filter (-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny) plus vm-manager's io_uring_setup denial, and when vm-manager runs as root (the chart's pod) QEMU and swtpm of each VM run as a user of their own (--vm-uid-base, one uid per VM, one group per network), started that way rather than dropping privileges themselves (-run-with user= would be killed by elevateprivileges=deny), with no capability in any set and no_new_privs. The VM's user owns only what its processes write (disk, variable store, console, tpm/, run/); vm-manager's own files of the VM stay root's; the network's group may only search the network's directory, and each VM's port there opens to that VM's own uid alone (internal/vm/isolation.go).
  • internal/network: one gvisor-tap-vsock VirtualNetwork per network (subnet, gateway, DHCP static leases keyed by the VM MAC, DNS, NAT to host, GatewayVirtualIPs including 169.254.169.254). Each VM's QEMU attaches to its own port, a unix socket per VM, with -netdev stream,addr.type=unix; port security drops every frame whose source MAC, IPv4 source or ARP sender is not the VM's lease. ListenIMDS serves IMDS inside the stack and names the VM behind each connection, port-forwards expose 6443. ssh to a guest never crosses the network: exec_vm dials the guest's sshd on its vsock CID, the only place it listens.
  • internal/imds: HTTP handler for the Giant Swarm provider, VM identified by the port its connection came through on the network whose listener accepted it (one handler per network).
  • internal/storage + internal/varlink: minimal JSON-over-AF_UNIX Varlink client; io.systemd.StorageProvider.Acquire on the fs provider creates per-VM target volumes (create=new,size=), attached as virtio-blk with serial=target; plain files below <state-dir>/volumes when no provider socket answers (storage.Detect).
  • internal/attest + internal/tpmquote: quote parsing and verification, expected PCR policy per image (policy.json), AK pinning per VM; the Recorder of the reference boot that records golden values (vm-manager image golden).
  • internal/images: catalog of base DDIs, UKIs, PCR policies and Kubernetes sysext versions.
  • internal/metrics: host stats per VM plus the last guest systemd-report upload, exposed as Prometheus families and through get_vm_metrics.
  • cmd/vm-agent: static guest binary, see below.

Guest image (images/)

mkosi project with two images (images/mkosi.images/base is the OS tree, the main image in images/mkosi.conf is the disk built from it, images/mkosi.images/kubernetes the sysext; images/README.md is the reference):

  • base: Arch, systemd 261, Bootable=yes UKI signed for PCR 11 (ukify with the build's PCR key), erofs root with Verity=data/hash/signature, ESP. Ships:
    • /usr/lib/udev/hwdb.d/45-imds-giantswarm.hwdb matching dmi:*:svnGiantSwarm:* with IMDS_DATA_URL=http://169.254.169.254/giantswarm/v1 and the key table below; kernel cmdline carries systemd.imds.import=yes so credentials are imported outside the initrd too.
    • /usr/lib/repart.sysinstall.d/: esp, root A/root-verity A/root-verity-sig A with CopyBlocks=auto, empty B slots (Label=_empty) for A/B updates, var.
    • /usr/lib/repart.d/: on the first installed boot creates the B slots sysinstall deferred and grows var.
    • vm-sysinstall.service: ConditionCredential=vm.install-target, runs systemd-sysinstall $TARGET --erase=yes --confirm=no --welcome=no --chrome=no --variables=yes --reboot=no --kernel=<UKI on the installer ESP> --copy-locale=no --copy-keymap=no --copy-timezone=no, forwarding no credential (vm-manager passes them over SMBIOS on every boot, and a sealed credential on the ESP would be loaded into every boot's initrd), then reboots with systemctl reboot itself (sysinstall's own reboot needs logind, which the read-only installer root cannot start). The stock interactive systemd-sysinstall.service is masked.
    • sshd with systemd-ssh-generator (AF_VSOCK port 22) and networkd DHCP.
    • /usr/lib/sysupdate.kubernetes.d/*.transfer: url-file source http://169.254.169.254/giantswarm/v1/sysupdate/kubernetes into /var/lib/extensions/kubernetes_@v.raw; /usr/lib/sysupdate.d/ for OS A/B updates from .../sysupdate/base; /etc/systemd/import-pubring.pgp holds the build key.
    • vm-agent (attestation only) with vm-agent-attest.service in the initrd and the real system, and vm-report-upload.timer (every 15 s) posting systemd-report upload to .../report.
    • persistent-etc.service in the initrd: var partition, /etc overlay with its upper directory on var, /root and /opt bind mounts, before initrd-root-fs.target; an exitrd so that systemd-shutdown can release the overlays and unmount var cleanly.
    • IPE: lsm=…,ipe and systemd.verity_root_options=root-hash-signature=auto on the UKI command line, the signed policy in the initrd (run only from kernel-verified dm-verity; kernel modules, firmware and kexec only from the base root, by its root hash), handed to the real root through /run/ipe, a manager drop-in that drops CAP_MAC_ADMIN once PID 1 loaded it, and persistent-etc keeping both out of the /etc overlay's reach.
    • The initrd (mkosi sub-image) contains systemd-networkd, systemd-imdsd, vm-agent and Ignition with its ignition-* units ported from upstream's dracut/30ignition (ignition-fetch, -disks, -mount, -files required by ignition-complete.target, which initrd.target requires; the services carry ConditionKernelCommandLine=ignition.firstboot; no fetch-offline, kargs or generator). The UKI cmdline carries ignition.platform.id=metal ignition.config.url=http://169.254.169.254/giantswarm/v1/user-data; vm-manager adds ignition.firstboot through the io.systemd.stub.kernel-cmdline-extra SMBIOS string only on the first installed boot. Ignition comes from a pinned upstream tag (images/Makefile IGNITION_VERSION, scripts/build-ignition); Arch has no official package. The initrd-stage attestation unit must be ordered Before=ignition-fetch.service.
  • kubernetes: sysext DDI with kubeadm, kubelet, kubectl, containerd, runc, crictl, cni-plugins and their units (started through Upholds= on multi-user.target, since presets cannot enable units of a layer merged during boot); extension-release.kubernetes_<kv> matching the base.

Build outputs per version (images/build/): giantswarm-vm-base_<v>.raw, giantswarm-vm-base_<v>.efi, sysupdate/base/ (split root, verity and signature partitions plus the UKI, SHA256SUMS, SHA256SUMS.gpg), kubernetes_<kv>.raw and sysupdate/kubernetes/ (kubernetes_<kv>.raw, SHA256SUMS, SHA256SUMS.gpg), policy.json (expected PCR 11 per phase path, PCR 13 per Kubernetes version, golden firmware PCRs once recorded). Signing keys (verity certificate, PCR key for the UKI, PGP for SHA256SUMS) are generated per build and kept in the git-ignored images/keys/; vm-manager only serves signed artifacts and never holds private keys.

Boot flow

Phase A, installer boot (no persistent disk yet):

  1. create_vm acquires a target volume, creates the swtpm state dir and OVMF vars copy, keeps a copy of the image's certificate, which every QEMU start writes into db (internal/uefivars), allocates a MAC + DHCP lease, stores user-data.
  2. QEMU starts with -kernel base_<v>.efi (direct UKI boot under OVMF), the base DDI attached read-only (serial=installer), the blank target (serial=target), swtpm via tpm-crb, -smbios type=1,manufacturer=GiantSwarm,product=vm-manager,serial=<vm-id>, and SMBIOS type 11 credentials: vm.install-target=/dev/disk/by-id/virtio-target, firstboot.hostname, ssh.authorized_keys.root, system.machine_id, vmm.notify_socket=vsock-stream:2:<port>.
  3. vm-sysinstall.service installs the booted OS onto the target: repart copies the root/verity/sig partitions bit-identically, creates the ESP and var (the B slots are deferred to the first installed boot), kernel-install installs the signed UKI with a Type #1 entry and no credential file, bootctl install adds the signed systemd-boot, then the unit reboots. QEMU runs with -no-reboot; vm-manager sees the exit and starts phase B. Measured: 12 s.

Phase B, installed boot (every boot from now on):

  1. OVMF -> systemd-boot -> UKI (measured into PCR 11 with .pcrsig), credentials from the ESP. In the initrd: verity root (its signature verified by the kernel against the certificate the firmware's db put on the platform keyring), repart creates the B slots and grows var, systemd-imdsd early network brings up DHCP from the virtual network, imds import (hostname, ssh key -> /run/credstore), persistent-etc.service mounts var, the /etc overlay, /root and /opt under /sysroot.
  2. Still in the initrd (implemented: images/mkosi.initrd.conf), vm-agent-attest.service (wanted by initrd.target, After=systemd-pcrphase-initrd.service so PCR 11 carries exactly enter-initrd, after the IMDS early network, Before=ignition-fetch.service through a drop-in on the fetch unit) runs vm-agent attest --stage=initrd --timeout=90s: a challenge for the VM's AK, its nonce recovered with the vTPM's EK (TPM2_ActivateCredential), a quote of PCRs 0-7, 11, 12 and 13 over it with the AK, posted with both event logs. vm-manager verifies and marks the VM attested; until then /user-data is 503 with Retry-After, which Ignition's fetch stage retries with backoff (see the IMDS contract). A rejected quote fails the unit visibly (exit 2), and vm-manager kills the boot: the VM is failed with the verdict, user-data never released. The unit is skipped on the installer boot and outside vm-manager (ConditionFirmware=smbios-field(sys_vendor = GiantSwarm)), never by a kernel command line switch; a boot of vm-manager's that skips it reaches READY=1 without a verified ready quote and is killed as well. Proven by e2e/attestation_test.go: verified quote, user-data applied by Ignition; a boot on a distribution's OVMF build rejected with a golden mismatch on PCR 0 and killed; and by e2e/attestation_skipped_test.go for the routes that skip the unit.
  3. Ignition (first boot only: ignition.firstboot on the cmdline) fetches the Ignition config from /user-data (ignition-fetch.service), runs its disks, mount and files stages, which write CAPI's files and systemd units (kubeadm config, the kubeadm unit) into /sysroot, then the initrd switches root. A VM without user-data gets 204 and the stages run with an empty config.
  4. Real system: PID 1 first loads and activates the signed IPE policy the initrd left in /run/ipe and then drops CAP_MAC_ADMIN from every process's bounding set (the usermode helpers lost it on the kernel command line); from here on only code from kernel-verified dm-verity volumes runs (images/README.md, IPE). A reboot of the guest ends QEMU (-no-reboot), and vm-manager starts the next boot as a new process. Then systemd-firstboot (machine-id, hostname, locale/timezone), networkd, then vm-kubernetes.service (base image, After=network-online.target systemd-imds-import.service systemd-sysext.service systemd-tpm2-setup.service, wanted by multi-user.target) reads /kubernetes-version and /cni-version from the IMDS and runs systemd-sysupdate --component=kubernetes update <version>, then --component=cni for the CNI sysext (one per CNI release, <cni>-<release>, the only place CNI plugins come from: containerd's bin_dirs is /usr/lib/cni alone) (explicit version selection; the artifact directory is served unfiltered because its SHA256SUMS is signed at build time), removes any other kubernetes_*.raw and cni_*.raw, merges the extensions with systemd-sysext refresh (daemon-reload via EXTENSION_RELOAD_MANAGER=1, Upholds= starts containerd and kubelet) and extends PCR 13 with systemd-pcrextend using each file's SHA256SUMS line (<sha256> kubernetes_<version>.raw, then the cni one), so the host computes PCR 13 from the artifacts (policy.json sysexts.<component>.<version>, images/README.md). A VM without a Kubernetes version skips the unit. CAPI's unit, ordered After=vm-kubernetes.service, runs kubeadm init|join and writes /run/cluster-api/bootstrap-success.complete. vm-agent-attest.service of the root (implemented: images/mkosi.images/base, After=vm-kubernetes.service systemd-pcrphase.service, Before=multi-user.target) runs vm-agent attest --stage=ready and posts a second quote covering PCRs 13 and 15 and the full phase path for get_vm_attestation. READY=1 (step 8) waits for vm-kubernetes.service and that quote; the e2e measures 14 s from the installed boot to ready with a 2 s download.
  5. PID 1 sends READY=1 over vsock; systemd-report upload pushes metrics on a timer. Measured: 11 to 15 s from the installed boot to READY=1 for the bare image, 11 s for a reboot to ready.

Fast path for later: pre-install on the host with systemd-repart from the same repart.sysinstall.d definitions against the base DDI (needs root or io.systemd.Repart), skipping phase A when TPM-bound install credentials are not needed.

Open points found while building waves 1 to 3

Each point starts with Implemented or Resolved and names the PR or test that closed it; open follow-ups are scheduled in plan.md.

  • PCR 13 and sysexts. Implemented (#27, e2e/kubernetes_sysext_test.go). systemd 261 measures only stub-loaded extensions (<uki>.efi.extra.d/*.sysext.raw on the ESP) into PCR 13, and those extend the initrd (/.extra/sysext/ is searched only there), not the installed root; the measured object is the stub's cpio archive, which a host cannot predict from the artifact alone, and the 206 MB would have to fit the 512 MB ESP before the first installed boot. Decided: vm-kubernetes.service extends PCR 13 itself after the merge with systemd-pcrextend and the file's SHA256SUMS line. PCR 13 of a boot is then exactly three events, "os-separator" (initrd, systemd-pcrosseparator.service), the Kubernetes line and the CNI line, each PCR := sha256(PCR || sha256(word)); images/scripts/verify-sysext writes the published sha256 of every sysext as sysexts.<component>.<version> into policy.json, and the ready-stage verifier computes the VM's Kubernetes x CNI pair from them with attest.SysextPCR (one entry per sysext, never per pair), and a VM without Kubernetes has the os-separator value alone; PCR 13 is never golden, and a VM whose versions have no entries is rejected. Verified end to end by e2e/kubernetes_sysext_test.go against the vTPM.
  • Volatile /etc. Implemented (#25, #30, e2e/persistent_etc_test.go): the image no longer boots with systemd.volatile=overlay. persistent-etc.service in the initrd mounts the var partition on /sysroot/var and an overlay on /sysroot/etc whose upper and work directories are /var/lib/etc-overlay/, plus /root and /opt as bind mounts from var, before initrd-root-fs.target; the root stays the read-only verity erofs. Firstboot's output, the machine ID, SSH host keys, enabled units and whatever Ignition writes to /etc survive reboots, and var is unmounted cleanly at shutdown: systemd-shutdown's exitrd (tmpfiles.d/vm-manager-exitrd.conf, run-initramfs-{root,usr}.mount) releases the /etc overlay and the Kubernetes sysext's /usr overlay, both pinned by PID 1's own mappings, which keep var's superblock alive, and its system-shutdown/vm-manager-var hook waits for the kernel's asynchronous tear-down of the sysext's loop device, which is what finally puts the superblock (e2e/persistent_etc_test.go; details in images/README.md, "Persistent state").
  • Ignition and /var. Implemented by the same change (#25, e2e/ignition_test.go): the var partition is mounted on /sysroot/var before initrd-root-fs.target, and ignition-files.service runs after it (After=initrd-root-fs.target sysroot-var.mount), so what user-data writes below /var, /etc, /root or /opt lands on the partition. A VM whose initrd quote is rejected is killed before its user-data is released (the tamper subtest of e2e/attestation_test.go).
  • No host loopback alias. No guest address is translated 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) stays reserved, never leased and not answered, so addressing is the same as when it was an opt-in alias.
  • Sysext file lifecycle. Implemented (#27). systemd-sysext merges every kubernetes_*.raw it finds and sysupdate.d(5) rejects InstancesMax= below 2, so vm-kubernetes.service deletes every kubernetes_*.raw other than the requested version before it refreshes; exactly one file, one merged extension, one PCR 13 measurement per boot. A changed /kubernetes-version takes effect on the next boot (no live switch of a running node).
  • PCR 1 and 5 are per VM. Implemented by event-log replay (#316, internal/attest/bootconfig.go, e2e/boot_config_attestation_test.go). They differ between two VMs on the same firmware and image, so attest.GoldenIndexes is 0, 2-4, 6 and 7: EDK2 measures the ACPI tables (sized for the VM) and the SMBIOS tables into PCR 1 (SmbiosMeasurementDxe, type 11 OEM strings are not filtered, and vm-manager's are per-VM credentials: hostname, machine ID, SSH key, notify socket), as is the Boot#### entry whose device path carries the ESP's partition GUID; PCR 5 holds the GPT of the installed disk with per-install partition UUIDs. The verifier replays the PCR 1 and 5 events of the firmware event log (and the initrd's os-separator from the userspace log) to the quoted values, every event one a boot vm-manager starts has and bound to its data where the log carries it. What the guest can change is judged: the GPT must hold the partitions of the image's installed disk and nothing else (installedDisk, kept equal to repart.sysinstall.d by a test: types, labels with the image's id and version or _empty, attributes, counts), so a partition added, retyped, relabelled or given another attribute fails the next boot; BootOrder, the Boot#### options and systemd-boot's loader.conf must be what the VM's first verified boot measured (the record's bootConfig; before that boot only vm-manager's installer wrote them). The ACPI and SMBIOS tables and the SMBIOS structures systemd-boot and systemd-stub measure come from QEMU and vm-manager's arguments; the guest cannot write them, they are replayed, not compared, so a host's QEMU update does not fail its VMs.
  • The ESP and the kernel command line. Implemented (#293, e2e/kernel_cmdline_attestation_test.go). The installed ESP is writable for root on a node. With Secure Boot off, systemd-stub used a command line a Type #1 entry's options passed instead of the UKI's own, and credentials or extension images on the ESP reach the initrd; PCR 11 sees none of it. Now the image signs its UKI and systemd-boot with its key and says so in policy.json (secure_boot); vm-manager enrolls the image certificate as PK, KEK and db before every start (uefivars.EnrollSecureBoot) and boots every VM on its own OVMF build with SMM and Secure Boot (firmware/README.md), so the stub ignores loader command lines; create_vm refuses an image without secure_boot. The installer puts no credential on the ESP (vm-manager passes them over SMBIOS on every boot) and the image turns off the pcrlock notification that would write one. Both stages quote PCR 12; the verifier replays the firmware event log and the userspace log's os-separator against it, binds every command line to its text and requires exactly what vm-manager passed (attest.Policy.KernelCmdlineExtra, the VM record's kernelCmdlineExtra, set when its installed boot starts), and rejects any credential or configuration extension archive: systemd-boot still measures an entry's options, so such a change also fails attestation. The initrd quote covers PCR 13 too and accepts only zero or the os-separator, so an extension image from the ESP fails the quote that releases user-data.
  • VM processes and vm-manager restarts. Resolved: QEMU and swtpm run as transient systemd services (systemd-run --service-type=exec -p RemainAfterExit=yes, units vm-manager-<id>-qemu and -swtpm in vm-manager.slice), started under the user manager when vm-manager is unprivileged and the system manager when it is root (internal/runtime/proc.SystemdExec). systemd is their parent, so a vm-manager exit leaves them running; --detach-vms-on-exit (default) makes Close hand them over and Load reattaches through the handles in vm.json (processes): volume, lease, swtpm, QEMU with QMP, notify subscription, supervisor. The exit status survives too: RemainAfterExit keeps ExecMainCode/ExecMainStatus until the watcher (a pidfd on the main process) has read them and releases the unit. --scope was rejected because a scope's process stays a child of vm-manager, its exit status is lost to a successor and its stderr pipe breaks with the parent; the service mode needs no cgroup delegation for vm-manager's own unit. Without a reachable service manager the launcher falls back to plain child processes and warns that VMs end with vm-manager.

IMDS contract (Giant Swarm provider)

Plain HTTP, GET http://169.254.169.254/giantswarm/v1<key>, text bodies, 404 with an empty body for unknown and unset keys (systemd-imdsd aborts an error response that carries body bytes before it reaches its own 404 handling; only a bodyless 404 becomes KeyNotFound, which systemd-imds --import tolerates for an unset key). /user-data is not an hwdb key: its client is Ignition's cmdline provider (ignition.config.url), not systemd-imds --import, and its status codes follow what Ignition v2.27.0 does with them: 200 with the raw Ignition JSON once released; 503 with Retry-After while gated, because internal/resource/http.go (shouldRetryHttp) retries every status >= 500 with a 200 ms backoff doubling to 5 s until --fetch-timeout (2 min by default), whereas 403 and 404 end the fetch stage at once (internal/resource/url.go fetchFromHTTP maps 404 to ErrNotFound, anything else to ErrFailed); 204 when the VM has no user-data, because an empty body parses as ErrEmpty (config/util/config.go), which the engine takes as "no config" and continues, while a 404 would drop the boot into emergency.target; 410 once the boot it was released to is past Ignition (its verified ready-stage quote or its READY=1, whichever comes first), when vm-manager drops it from memory and the state directory for good. No later boot runs Ignition (ignition.firstboot is passed only until then), so the 410 reaches only what has no business reading user-data, such as a pod on the node. The Go key table is the single source of truth and generates the hwdb record at image build time.

Key hwdb property Content
/hostname IMDS_KEY_HOSTNAME VM name
/region, /zone IMDS_KEY_REGION/ZONE host name, network name
/public-keys/0 IMDS_KEY_SSH_KEY first authorized key
/user-data none (Ignition's ignition.config.url) CAPI bootstrap data as Ignition JSON; 503 + Retry-After while gated by attestation, 204 when the VM has none, 410 once the first boot consumed it
/instance-id, /kubernetes-version, /cni-version, /metadata/<k> extra plain values
/layer-certificates extra the installation's layer certificates of create_vm as concatenated PEM in the caller's order; 404 when none
/attest/challenge, /attest/quote agent only attestation protocol below
/report agent only systemd-report upload sink
/sysupdate/<component>/ sysupdate SHA256SUMS, SHA256SUMS.gpg, artifacts; served unfiltered, the guest picks the version from /kubernetes-version and /cni-version

Attestation protocol: POST /attest/challenge with JSON {ak_pub} (the attestation key's TPMT_PUBLIC) returns {credential_blob, encrypted_secret}: a fresh 32-byte nonce, valid 5 minutes and once, sealed for that key under the VM's endorsement key the way TPM2_MakeCredential does. vm-manager reads the EK (the TCG default RSA 2048 template) from the VM's vTPM itself, before the VM's first QEMU (internal/tpm EndorsementKey, over a data channel of its own), and keeps it in the VM's record. The agent recovers the nonce with TPM2_ActivateCredential, which only the vTPM holding that EK performs, and only for the key the credential names while it is loaded there. POST /attest/quote with JSON {stage, nonce, ak_pub, quote, signature, pcrs:{sha256:{"0":..}}, event_log, userspace_log} (binary fields base64, stage is initrd or ready). Verification: the nonce was sealed for ak_pub, so the key is certified against the VM's EK, the first quote of the VM's first boot included; signature over the quote with ak_pub, nonce match, PCR digest matches pcrs, PCR 11 equals the value computed with systemd-measure calculate for the image's UKI and the stage's phase path (enter-initrd for initrd, enter-initrd:leave-initrd:sysinit:ready for ready), PCRs 0, 2-4, 6 and 7 equal the image policy's golden values recorded by vm-manager image golden (PCR 1 and 5 differ per VM: the firmware event log is replayed against them, see the point above), and at ready PCR 13 equals the value computed from the policy's sysexts entries of the VM's Kubernetes and CNI versions (written by images/scripts/verify-sysext; the os-separator alone when the VM has none). The image's policy.json declares "pcr15": "layer-certificates" when its initrd measures layer certificates (images/scripts/verify writes it): the ready quote of such an image must cover PCR 15 whether or not the VM is served certificates, since the guest picks the PCRs it quotes and "none served" is proven as "none measured". An image whose policy lacks it predates layer certificates: it may leave PCR 15 out (the verdict says so) and is rejected when the VM is served certificates, which it cannot enroll. A quoted PCR 15 is always verified: the verifier replays the PCR 15 records of userspace_log (systemd's /run/log/systemd/tpm2-measure.log) to the quoted PCR 15. Every PCR 15 record is bound to its content before it is replayed: a systemd string record whose sha256 digest is the sha256 of its word, the word a machine-id:, file-system: or layer-certificate: measurement; any other record (another content type, a digest that is not its word's, an unknown word such as systemd-cryptsetup's HMAC of a volume key) rejects the quote. The layer-certificate:<sha256 of the DER> words must name exactly the certificates /layer-certificates serves, in order (none served, none measured); the initrd extends PCR 15 with one such word per certificate before it seals the .dm-verity keyring, and get_vm_attestation shows the digests the node measured (ready.layerCertificates). Only the initrd stage unlocks /user-data; the ready stage makes the boot ready. The certified AK of the first verified initrd quote is pinned and kept in the VM's record across restarts of vm-manager.

Every quote is verified; nothing in serve turns that off or accepts a PCR without a golden value. A rejected quote at either stage, READY=1 without a verified ready-stage quote of the same boot, and a boot without one by --boot-timeout all end the boot: QEMU is killed and the VM is failed with the reason. Golden values are recorded once per image and firmware build, by the build and release pipeline: vm-manager image golden <image> boots a reference VM in its own process (attest.Recorder: every check but the golden comparison, no user-data), writes the PCRs of its ready quote as golden.sha256 and the firmware build as golden_firmware into the image's policy.json (which images/scripts/verify preserves across rebuilds of the same version), and boots a fresh VM that must verify against them. The release pipeline runs it for every release on the release's container image, its vm-manager, QEMU, swtpm and firmware (hack/guest-image-golden.sh), so a released guest image artifact carries them; a local build records its values the same way. A golden mismatch of a firmware PCR names the build the values were recorded for next to the one the server boots.

How CAPI fits

CAPI's kubeadm bootstrap provider writes cloud-config (or Ignition) into a Secret and expects an infrastructure provider to hand it to a VM that runs it and registers as a node. With vm-manager:

  1. cluster-manager (or an agent) creates a network for the cluster (create_network), sets KubeadmConfig format: ignition and calls create_vm with user_data set to the bootstrap Secret's Ignition JSON, plus kubernetes_version, that network and sizing. create_vm refuses user_data on the network the server creates at startup (--default-network): every caller's VMs share that one L2 segment, so a node bootstrapped there would sit next to other clusters, reachable on its address and its ARP. A network per caller instead would need a caller identity the API does not keep (every authenticated caller may use every network), and a CAPI provider has the cluster to create the network for anyway. The default network stays for VMs without user-data. The kubeadm unit must be ordered After=vm-kubernetes.service (one line through additionalConfig): that unit pulls the sysext with kubeadm, containerd and kubelet, applies its modules and sysctls and waits for containerd, so kubeadm's preflight passes on the first boot.
  2. The VM installs (phase A), boots (phase B), attests from the initrd, and only then does Ignition receive the user-data and write CAPI's files and units; kubeadm runs from those.
  3. The node's providerID is giantswarm-vm://<name>, set via kubelet extra args in the KubeadmConfig: user-data is fixed when create_vm is called and the id is only known afterwards, so the caller keys it by the VM name it chooses (the Machine name); get_vm reports IP, attestation, and readiness so the caller can set the infra Machine ready when the node registers.
  4. Control plane endpoint: v1 uses the first control plane VM's IP (kubeadm's default advertise address; no controlPlaneEndpoint) and a host port-forward for 6443, with apiServer.certSANs: [127.0.0.1, localhost] so the admin kubeconfig works through forward_port; multi control plane later uses kube-vip on a reserved IP of the network, which port security drops until the network admits that address on the control plane VMs' ports.
  5. READY=1 is sent when the boot transaction is complete, and the kubeadm unit is part of it: a VM with user-data reaches ready only after kubeadm init|join succeeded, which makes get_vm state ready the bootstrap signal. The server's --boot-timeout (default 4 min) must cover kubeadm init with its image pulls, or the VM is reported running with a lastError although nothing failed; the caller should either raise it or use wait_for: installed and poll.
  6. Remediation is delete + recreate. A thin CAPI infrastructure provider (or cluster-manager glue) that wraps this API is a follow-up.

Proven by e2e/kubernetes_cluster_test.go (make e2e), which runs exactly this through the MCP API. The user-data is Ignition 3.4.0 with two files and one enabled unit, the shape of CAPI's bootstrap/kubeadm/internal/ignition/clc/templates: /etc/kubeadm.yml (0640, the kubeadm config), /etc/kubeadm.sh (0700: kubeadm init|join --config /etc/kubeadm.yml, then /run/cluster-api/bootstrap-success.complete, then the config is moved to /tmp) and kubeadm.service (Type=oneshot, ExecStart=/bin/bash /etc/kubeadm.sh as CAPI 1.14 writes it, ConditionPathExists=/etc/kubeadm.yml, After=network-online.target vm-kubernetes.service, WantedBy=multi-user.target). The kubeadm config is kubeadm.k8s.io/v1beta4: for the control plane InitConfiguration (nodeRegistration.criSocket: unix:///run/containerd/containerd.sock, kubeletExtraArgs: [{name: provider-id, value: giantswarm-vm://cp-1}]), ClusterConfiguration (kubernetesVersion, imageRepository: gsoci.azurecr.io/giantswarm, networking.podSubnet: 10.244.0.0/16, the SANs above) and KubeletConfiguration (cgroupDriver: systemd); for the worker JoinConfiguration with discovery.file (a kubeconfig of <cp ip>:6443, the cluster CA and the token from kubeadm token create --print-join-command on the control plane, since the API server answers no cluster-info request without credentials; docs/reference-cluster.md "Joining nodes") and the same nodeRegistration. Measured on the hosted e2e runner, on the IPE image with Cilium and every image signed: the control plane is Ready with every pod running 93 to 125 s after its create_vm (kubeadm init 17 to 24 s, installed boot to READY=1 34 to 48 s); the worker is Ready 71 to 121 s after its create_vm (kubeadm join about 2 s), most of it pulling Cilium; mirroring and signing the nine images on the host takes 22 to 60 s.

What sysinstall/firstboot do not cover: writing CAPI's files and units (Ignition) and proving integrity before secrets are released (vm-agent attest).

MCP tool surface (v1)

Read-only: get_info, get_host, list_images, get_image, list_networks, get_network, list_vms, get_vm, get_vm_console, get_vm_metrics, get_vm_attestation. Writes: create_network, delete_network, create_vm (name, image, kubernetes_version, cni_version, cpus, memory_mib, disk_gib, network, user_data, hostname, metadata, layer_certificates, wait_for none|installed|attested|ready), start_vm, stop_vm, reboot_vm, delete_vm, exec_vm, forward_port. REST mirrors each under /api/v1.

Testing strategy

Tier Target Budget Runs Runs on
T0 unit every package with fakes (fake runtime, fake storage, httptest IMDS, CAPI Ignition fixtures, go-tpm simulator) < 30 s every PR test.yml, ubuntu-latest; make test vet-e2e also compiles the e2e tag, make lint lint-e2e lints it
T1 contract in-process MCP client over httptest against the fake runtime; REST parity via statusFor < 10 s every PR test.yml, ubuntu-latest
T2 image mkosi build + image-verify: systemd-dissect, ukify inspect, systemd-measure calculate minutes every PR touching images/, vm-agent or the workflow; push to main; nightly through e2e image.yml, archlinux:latest container (--privileged) on ubuntu-26.04, no mkosi cache (the current Arch repositories, as the release's guest-image job); artifact guest-image
T3 boot e2e Go tests tagged e2e with the real runtime on KVM (e2e/): install + reboot + READY, IMDS + firstboot, Ignition files + units applied, persistent /etc, sysext merged and measured, IPE enforced and locked, attestation record / golden / tamper and the routes that skip it, 1 CP + 1 worker from CAPI-shaped Ignition (skipped for an image with IPE) < 90 s per test except the cluster (2.5 to 3 min) and attestation (111 s for three servers); about 6 min for the suite, 45 m go test ceiling every PR and push to main: fast subset (install/boot, IMDS including networks with overlapping CIDRs, persistent /etc, sysext, IPE); nightly and manual: the full suite e2e.yml, hosted ubuntu-26.04 with nested KVM and vhost_vsock, qemu/swtpm/ovmf from apt, the guest-image artifact built in the run or reused from main; developers run make e2e on their KVM host

Boot-time budgets were set at installer phase to reboot < 60 s and installed boot to READY < 10 s; measured on the development host: install 12 s, installed boot to READY=1 11 to 15 s (the sysext pull and the ready-stage quote are inside that), reboot to ready 11 s. The e2e tests print these as install_seconds=, boot_to_ready_seconds=, reboot_to_ready_seconds= and enforce generous ceilings; the metrics export them per VM (vm_manager_vm_install_seconds, vm_manager_vm_boot_to_ready_seconds).

Host prerequisites

For vm-manager serve: qemu-system-x86_64, vm-manager's own OVMF build (make firmware), swtpm, systemd (systemd-ssh-proxy only for a person's own ssh root@vsock/<cid>), /dev/kvm and /dev/vhost-vsock accessible by the service user, optionally systemd 261's io.systemd.StorageProvider (plain files otherwise). For the image build: mkosi >= 27, erofs-utils, pefile, gnupg, util-linux (sfdisk), Go 1.26+. For the cluster e2e additionally kubectl and internet access from the VMs. install.md has the packages and the device permissions.