Skip to content

Latest commit

 

History

History
222 lines (203 loc) · 13.3 KB

vm-manager.md

File metadata and controls

222 lines (203 loc) · 13.3 KB

vm-manager

The platform's VM provisioner (giantswarm/vm-manager) in the lab: KVM virtual machines with an instance metadata service, a vTPM with measured boot, an immutable image and attestation, exposed to muster and the agents as x_vm-manager_<tool> and to the portal as one more server of the Agent Platform group. vm-manager is the sibling of agent-manager (agents) and model-manager (models) — the write surface for VMs — and runs the way they do: as a pod, the agent-platform chart's components.vm-manager. The kind node is a privileged docker container, so the host's /dev/kvm and /dev/vhost-vsock are in it, and the runtime hands them to the privileged pod (nothing is mounted from the node; the chart has no hostPath); QEMU and swtpm are the pod's children. The guest image the pod boots is an OCI artifact its init container fetches into the pod's state volume: the one every vm-manager release publishes (gsoci.azurecr.io/giantswarm/vm-manager-guest-image:<version>, the chart default), or a local build the lab pushes into its registry.

What the lab does

platform.vmManager in agentlab.yaml:

platform:
  vmManager:
    enabled: true
    imageDir: /home/you/projects/giantswarm/vm-manager/images/build   # optional: a local guest image build (`make -C images`); empty boots the release's
  devImages:
    vm-manager: vm-manager:dev                                        # optional: a build of the checkout's binary (`make docker-build`)
  • agentlab configure reports whether this machine has the KVM devices (KVM /dev/kvm and /dev/vhost-vsock present — platform.vmManager on, the release's guest image or … a local guest image build from …). A machine without them turns the key off with the reason; a machine with them keeps what the file says — the pod is a heavier piece of the lab than a model server, so it is never turned on by itself. --vm-manager[=false] pins it, --vm-manager-image-dir <dir> names a local build.
  • agentlab up / agentlab platform refuse the key on a node without the devices, with the fix. With imageDir set, platform pushes the build into the guest image registry as vm-manager-guest-image:dev with vm-manager image push — the same code the release pipeline runs — signed with this machine's build key, and records the manifest digest in state/vm-manager-guest-image.json. A rebuilt image is a new digest: the next platform rolls the pod, whose init container replaces the directory.
    • vm-manager reaches no registry over plain HTTP and accepts no unsigned guest image, so a local build is signed and served over TLS. The guest image registry is a zot container of its own, <cluster>-guest-registry:5000 on the kind network, at the release the lab registry runs (nothing new to pull). It serves HTTPS only, under a CA of its own in state/guest-registry/: the lab CA's name constraints admit the platform domain alone. The CA goes to the pod as the ConfigMap vm-manager-guest-registry-ca. The lab registry keeps everything else (charts, the Harness dev image).
    • The build key is the one make dev-signing-key makes in the vm-manager checkout ($XDG_STATE_HOME/vm-manager/dev-signing.key, or VM_MANAGER_GUEST_IMAGE_SIGNING_KEY). Only a vm-manager built from source with it (make docker-build) trusts it; a released one trusts its release's signature alone. So a local build needs platform.devImages.vm-manager, and platform checks with vm-manager image trust that the dev image trusts the key before it pushes, and refuses with the fix otherwise.
    • The chart that takes guestImage.registryCA is vm-manager 0.30 or newer: an older chart's closed guestImage block refuses the values, and the render says so.
  • agentlab platform turns components.vm-manager on in the chart's values: the meta chart's own vm-manager: block brings the pinned Service name, OAuth against global.identity (the lab Dex; vm-manager has no anonymous mode and no switch for one from 0.30) and the muster MCPServer with the agent-platform tool group and forward-token auth; the lab adds guestImage (the guest image registry, by digest, its CA as registryCA) when a local build is configured and a state claim (persistence.create: true, the node's local-path storage) so the fetched image, its golden PCR values and the lab's VM records survive a pod restart. The pull always verifies the signature: the release's on the release's own guest image, the build key's on a local build. A vm-manager whose own NetworkPolicy is always on admits on its API port only the callers its values name and lets out only DNS, the in-cluster peers its values name and every public address (its guests share the pod's egress), never the cluster's networks. The lab names its own (networkPolicy in the values): muster and the probe pods of vm-manager-test as callers, the lab Prometheus's namespace while it scrapes, the lab Dex as a peer and, for a local guest image, the guest image registry's address on the kind network. It sets them when the chart takes them, which it finds out by rendering the vm-manager release once more with the probe pods as a caller (an older chart, whose policy is off by default, refuses the key). A platform.devImages.vm-manager build is side-loaded into the node and swapped in like model-manager's (both containers of the pod run it). The run waits until muster reports the registration reachable.
  • The release's guest image download is sized before the install. The pod's init container downloads the artifact (1,677 MiB for 0.24.10) with vm-manager's own client before the pod is Ready, and Flux's default 5-minute timeout does not fit that on a home uplink: the install would time out, be uninstalled and download from zero again (giantswarm/vm-manager#240). agentlab platform reads the reference off the vm-manager render, sizes the artifact from its manifest and sets components.vm-manager.timeout to 5 minutes plus the download at 1 MiB/s (33m for 0.24.10); its own install wait grows by as much. Unless the running pod already holds that image, it samples the link on the artifact's largest file (8 MiB or 8 s) and refuses a link too slow for that bound before anything is installed, with the measured rate, the estimate and the fixes. A local build (imageDir) comes from the guest image registry and is not sized.
  • agentlab vm-manager-test is the proof (below).

An agentlab before 0.44 registered a vm-manager running on the host (state/vm-manager.env, a lab-created MCPServer); agentlab platform removes that registration before the install — the chart renders one of the same name — and the environment file with it.

Recording the image's golden PCR values

A released guest image artifact (vm-manager 0.23.0 and later, the pod's default when platform.vmManager.imageDir is unset) carries the golden values its release pipeline recorded for the same release's firmware (golden.sha256 and golden_firmware in its policy.json): the pod verifies both quotes of its first VM, nothing to record. vm-manager attests every VM and has no mode that accepts a boot without golden values (0.30 and later): a VM of an image without them is killed at its first quote, and vm-manager-test refuses to boot one, naming the image.

A local build (imageDir) carries PCR 11 (the UKI) and PCR 13 (the Kubernetes sysext) but no golden values for the firmware PCRs. Record them the way the release pipeline does, before the lab pushes the build, in the vm-manager checkout and with the vm-manager image the pod runs: the firmware is the pod's OVMF (Ubuntu 26.04's, inside the vm-manager image), not the host's, and values recorded for another firmware fail every quote (golden mismatch on PCRs 0 and 7, naming the build they were recorded for).

# in the vm-manager checkout, on a KVM host with no other vm-manager running
# (vsock CIDs are host-global); <vm-manager image> is the pod's
hack/guest-image-golden.sh <vm-manager image> <image dir>

The script boots a reference VM of the image in a container of that vm-manager image, writes the PCRs of its ready quote and the firmware build into the directory's policy.json, and verifies a fresh VM against them. The values then travel inside the artifact the lab pushes: list_images reports them and agentlab vm-manager-test reads both quotes verified. A rebuilt local build, or a vm-manager release that moves the firmware, is recorded again.

The firmware PCRs follow the vm-manager release, not the guest image. PCRs 0, 2, 3 and 7 measure the OVMF the pod boots with: ovmf-generic of the vm-manager image, pinned in its Dockerfile since vm-manager 0.22.12. A release that moves the pin is a pull request and a release note of its own, update OVMF to <version>, re-record golden PCRs. It changes PCR 0 while the guest image, its digest and the values on the state claim stay as they were, and every quote then fails with golden mismatch: pcr 0 (vm-manager-test names this when the VM fails, with this recipe as the fix). get_host reports the build the pod boots with as firmware (the code image's SHA-256, the package and version), and vm-manager-test prints it next to the host. A release that moves the pin ships values for the new build in its guest image artifact; a local build's values are recorded again after every change of it. Before the pin, 0.20.2 → 0.21.0 moved the unpinned ovmf from 2025.11-3ubuntu7 to 2025.11-3ubuntu7.2 and changed PCR 0 alone (PCRs 2, 3, 4, 7 and 13 kept their values).

The proof

agentlab vm-manager-test [email] [--skip-vm] [--vm-timeout 6m]
  1. The identity boundary, against the pod's Service from inside the cluster (a probe pod, the way muster dials it). GET /api/v1/host and GET /metrics without a token answer 401; with the person's Dex id_token — the very token muster forwards — the host answers the capability report (ready, missing, the kernel, CPUs, memory). A vm-manager that answers anonymously (a release before 0.30), or refuses the lab's token (another issuer, CA or audience), fails here with the fix. With platform.observability the lab Prometheus reports the vm-manager target up: its ServiceMonitor presents the chart's scrape token (Secret vm-manager-metrics), the only credential besides an OAuth token that /metrics takes.
  2. Through muster as the person. The x_vm-manager_* tools are aggregated — the core set of nineteen — with vm-manager's annotations intact (get_host read-only, delete_vm destructive: what a model reads before it calls); get_host names the same host as the direct call; list_images and list_networks answer (an image without golden PCR values is reported as such).
  3. The registration. The chart's MCPServer carries the agent-platform tool group and reads Connected.
  4. The lifecycle (unless --skip-vm, and only on a host that reports ready with an image): create_vm on the newest image (1 CPU, 1 GiB, an 8 GiB disk, wait_for: none), the states followed with get_vm — the installer boot, the installed boot, READY=1 over vsock — until ready, with the install and boot durations; get_vm_attestation with both stages verified (an image without golden values is refused before create_vm: vm-manager would kill its VM at the first quote); on a signed image (one whose artifact carries its certificate, <id>_<version>.crt, which create_vm enrolls into the VM's UEFI db — vm-manager 0.28 and later) exec_vm reads the guest's IPE state as root, one file per call (the kernel writes each flag without a newline): /sys/kernel/security/ipe/policies/giantswarm-vm/active and /sys/kernel/security/ipe/enforce both 1; the last console lines; delete_vm, and list_vms without it. A failed boot carries vm-manager's lastError (a refused attestation names the quote and the verifier's reason, a golden mismatch what changed) and the console tail. A leftover of an interrupted run (agentlab-vm-test-*) is removed first.

The lab's platform-test keeps its tool-group check: the chart's servers (agent-manager, model-manager, vm-manager) carry the platform group from their templates; nothing lab-created may claim it (the lab's family members carry infrastructure from their charts, the OAuth fixture no label).

Interactive use

Through the lab muster as an MCP server (https://muster.127.0.0.1.nip.io/mcp): x_vm-manager_get_host first, then x_vm-manager_list_images and x_vm-manager_list_networks, then x_vm-manager_create_vm — the server's own instructions say the order. In the portal, the MCP servers page lists vm-manager under Agent Platform; an agent with a toolset that admits it can provision VMs as the person who asked. agentlab logs vm-manager follows the pod (--verbose is on in the lab's values for a dev image).

The pod's VMs end with the pod: a agentlab platform that rolls the Deployment (a new dev image, a new guest image digest, changed values) stops every VM; their records and disks stay on the state claim for the next start_vm. The pod's policy is the chart's own (above); the connectivity chart's vm-manager policies join it only with platform.networkPolicy.