Repository navigation
Description
Slice 2 of the P6-on-Kubernetes epic: P4 microVM hosts attached to an in-cluster relay
Part of epic #426. Written so a planner can start it in a fresh session. Depends on slice 1.
Goal
P4 is the only part that still needs a VM or bare metal. A KVM host, outside the cluster, runs microvm-worker under systemd, as in deploy/microvm/. It dials the relay of a slice-1 cluster over TLS and serves authenticated mocactl turns.
This slice targets a P4-only stack: one P4 host and no container-sandbox pods. Slice 3 lifts both restrictions. The reasons are in "Limits" below.
Work
-
Expose the relay's attach port outside the cluster with TLS. Use a LoadBalancer with TLS, or TLS passthrough to a relay that serves TLS.
microvm-workeralready supportsRELAY_TLS=truewith the system root CAs (remote-worker/cmd/microvm-worker/main.go:646-680). Only the attach port is exposed; the exec port never is.- Attach is a long-lived gRPC stream. Check the load balancer's idle timeout against the worker's keepalive, and record what was measured.
- A NetworkPolicy admits the P4 hosts' CIDR to the attach port only.
-
Add a remote-relay mode to
deploy/microvm/setup-microvm.sh. Today it assumes P6 runs on the same host:- it reads
SH_RELAY_PORTfrom P6'srelay.env; - it writes a
sh-relay.servicedrop-in carryingSH_RELAY_TOKEN_<id>; - it waits for the presence record with
podman exec sh-redis.
Remote mode takes
RELAY_ADDR(and TLS) as input, generates the per-sandbox token as now, and prints the Secret entry the cluster side must add instead of writing a relay drop-in. It waits for attach some way other than local Redis: the worker log, a relay status endpoint, or an operator-runkubectlcheck. The co-located mode keeps working unchanged. - it reads
-
Register per-sandbox tokens without restarting the relay. The relay reads
SH_RELAY_TOKEN_<id>from its environment at boot. On Kubernetes, adding a P4 host would therefore mean restarting the single relay, which drops every attached sandbox and fails in-flight turns. Read the per-sandbox tokens from a mounted Secret file and reload it, without changing the fail-closed semantics inmakeDefaultValidateToken. -
Docs: an addition to
deploy/microvm/P4-ON-P6.md, or a sibling page, for the Kubernetes case.
Limits (by design in this slice, lifted by slice 3)
- One tier per stack.
selectPoolSandbox(harness/src/select-sandbox.ts) picks the least-loaded of all presence records on every turn, and records carry no tier label. With container pods and a P4 host on one relay, a session's turn 2 can land in a container and lose turn 1's microVM workspace (P4-ON-P6.md, "A P4-only host"). A cluster wanting both runs two stacks, one namespace each, with separate Redis and relay. - One P4 host per stack. The workspace is keyed by session id on the worker host's disk (
select-sandbox.ts:446-456), and selection has no session-to-sandbox affinity. With a second host, a later turn can open an empty workspace. - The golden snapshot is restored only on the instance type it was built on, so P4 hosts must be homogeneous.
- The P4 guest still has no network (P4.1: implement microVM egress transport (vsock → shared proxy) #277).
Not chosen: P4 as a privileged DaemonSet on a KVM node pool
It is possible, but it fights the jailer, the microvm-vms.slice cgroup layout and hostPath state. Revisit only if external hosts prove unworkable.
Acceptance
- An authenticated
mocactlturn on the slice-1 stack runs its tool calls in Firecracker microVMs on an external host, over TLS. - A second turn of the same session sees the first turn's files.
- Adding the host's token does not restart the relay.
- A sandbox credential cannot reach the exec port from outside the cluster.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
pdettori commentedon Oct 5, 2026
Slice 2 (#424) live acceptance: OpenShift 4.20.8 plus the shared KVM rig
Result: PASS. A P4 microVM host outside the cluster attached to the in-cluster relay over TLS. It served authenticated turns for two users, and adding a host did not restart the relay. Both sides were then restored.
feat/424-p6-k8s-slice2@5a69c0bc3bdb21:image-registry.openshift-image-registry.svc:5000/moca-build/moca-harness@sha256:99aa5c99d8ec9023f18b2acecbcf95801dd95705f36864a1ea69bcc60acc9f08.5a69c0bonly changessmoke.shand its test, which run on the operator's machine.apps.moca1.kubestellar.org, nodes on kernel5.14.0-570.73.1.el9_6microvm-workerwas built fromc3bdb21and installed withsetup-microvm.sh --remote. Guest kernel6.18.44+.Steps (spec §8)
SH_SANDBOX_COUNT=0 SH_P4_SANDBOX_IDS=moca_microvm_0 deploy/k8s/setup.sh --target ocp --image <above>.moca-relay-moca.apps.moca1.kubestellar.org.2/2(relay plus TLS sidecar), behind passthrough Routemoca-relay.curl -v https://moca-relay-moca…from the rig completed the TLS handshake, withALPN: server accepted h2(the--alpn h2fix, confirmed live) and the self-signed certificate.scp -rand installed withsudo … setup-microvm.sh --remote ~/moca-p4-moca_microvm_0, which printedmoca_microvm_0 is attached to the relay at moca-relay-moca.apps.moca1.kubestellar.org:443. On the cluster side,sh:sandbox:records=moca_microvm_0. The worker loggedtls=trueand a singleattached. The bundle copy was deleted after install.smoke.sh --target ocp --tier p4, real model (Anthropic API):moca_microvm_0/turnrefusedtoken_required6.18.44+vs nodes5.14.0-570.73.1.el9_6.x86_64attach=0 exec=12SMOKE_P4_ADD_ID=moca_microvm_scratch)sandbox-relay-cb564b8f7-hh9pp, start02:40:58Z, 0 restarts) was unchanged. The scratch ID's token and bundle were removed again.The first run passed 8/8. Its P3 line exposed a defect, described under Findings. After the fix, the smoke was re-run with P7 skipped: 7/7.
mocactlran for both slice-1 GitHub users, after a fresh device-flow login for each.doctorpassed 7/7 for both.6.18.44+.mocactl sessionslists only their own sessions.stream ended, so the Route'stimeout: 5mplus the worker's 30 s keepalive hold over the router.setup-microvm.sh(local mode) was re-run with the original binary, rebuilt on the rig from its checkout (fd6fed2). Its sha25683d47cee…is byte-identical to the one recorded before the run.50-moca-p6.confis back; the remote drop-in and the CA file are gone.tls=false), and the staging files were removed./opt/serverless-harnesswas never touched.SH_P4_SANDBOX_IDS= SH_SANDBOX_COUNT=2 setup.sh --target ocp --image <slice-1 digest>. Revocation ran clean on the real API server.moca-setupis identical to its pre-run value.smoke.sh --target ocppassed 11/11.Findings from the live run
5a69c0b): P3 was vacuous against a real model. The tool_result preview is a JSON envelope, so P3 compared the whole envelope against the node kernels, a comparison that could never fail. P3 now extracts the text, requires a kernel-release shape, and then rejects any node kernel. A regression test uses the real envelope format. The corrected P3 then passed live with6.18.44+.microvm-workerbinary before--remotereplaced it. The restore rebuilt it from the rig checkout's commit; see the restore section.setup.shaccepts several P4 IDs. One attached host per stack is a documented limit until Sandbox tier selection and session-to-sandbox affinity in selectPoolSandbox (P6-on-K8s slice 3) #425.docs(specs): P6 on Kubernetes, slice 2 design — external P4 hosts ove…
feat(sandbox-relay): per-sandbox tokens from SH_RELAY_TOKEN_DIR, read…
fix(sandbox-relay): exclude reserved name DIR from token lookup (#424)
feat(remote-worker): RELAY_CA_FILE adds a trusted CA for the relay's …
fix(remote-worker): restore TLS handshake verification and clean up t…
feat(deploy/k8s): the relay mounts optional per-sandbox tokens (#424)
feat(deploy/k8s): OpenShift p4-relay component — relay TLS sidecar, p…
feat(deploy/k8s): setup.sh takes sticky SH_P4_SANDBOX_IDS, one tier p…
fix(deploy/k8s): setup.sh fixes for slice-1 spec ref, glob expansion …
fix(deploy/k8s): normalize_p4_ids bash 3.2 compatibility and newline …
fix(deploy/k8s): bash 3.2 test exercises empty-input bug path (#424)
5 remaining items
feat(deploy/microvm): setup-microvm.sh --remote attaches a P4 host to…
fix(deploy/microvm): --remote attach must hold a settle window, so a …
fix(deploy/microvm): --remote attach must see no reconnect churn acro…
feat(deploy/k8s): smoke.sh --tier p4 — P4 records, microVM turns, rel…
fix(deploy/k8s): smoke.sh --tier p4 guards P3's kernel read, restores…
docs: P4 on Kubernetes runbook; slice 2 spec matches the implementati…
docs: slice 2 spec and P4 runbook review fixes (#424)
fix(deploy/microvm): --remote attach wait is wall-clock bounded; ATTA…
fix(deploy/k8s): refuse P4 ID DIR, print the re-copy rm, default the …
fix(deploy/k8s): smoke.sh P3 reads the kernel out of the tool_result …
docs(specs): P6.2 implemented — accepted on OpenShift with an externa…
fix(supervisor): K8sObject metadata declares annotations, for the def…
Merge pull request #437 from pdettori/feat/424-p6-k8s-slice2
ci: run the deploy bash suites under bash 3.2 on macOS