Skip to content

feat(k8s): run one shared supervisor per node - #6074

Open
Gal-Zaidman wants to merge 6 commits into
ai-openshell:mainfrom
Gal-Zaidman:feat/6026-node-supervisor-topology/Gal-Zaidman
Open

Gal-Zaidman wants to merge 6 commits into
ai-openshell:mainfrom
Gal-Zaidman:feat/6026-node-supervisor-topology/Gal-Zaidman

Conversation

@Gal-Zaidman

Copy link
Copy Markdown
Contributor

Summary

Add a node supervisor topology for Kubernetes. One shared supervisor runs on each node as a DaemonSet, and each sandbox is served by the supervisor on the node its workload Pod is scheduled to. RFC 0018 records the per-node model.

Related Issue

Closes #6026

Changes

  • RFC 0018: decides the per-node model.
  • Supervisor identity: shared supervisors can present a projected ServiceAccount token (audience openshell-supervisor) that binds a session to its Pod and node. The gateway verifies any token it receives. require_identity_token (Helm supervisor.requireIdentityToken, default false) makes the token mandatory, and node topology always requires it.
  • Driver: supervisor_topology = "node" binds pool members to nodes. After the scheduler binds the workload Pod, the driver launches the sandbox on that node's supervisor. If the launch can't be placed, the bootstrap rolls back.
  • Pool: node-topology instances are pinned to their node's supervisor for placement and takeover.
  • Helm: supervisor.topology: node renders the supervisor as a DaemonSet (rolling with maxSurge: 0, maxUnavailable: 1) and caps the per-member instance limit at 1,024.
  • Docs and skills: the gateway configuration reference, the Kubernetes HA guide (including the upgrade order for requireIdentityToken), the driver and supervisor-control READMEs, the debug skill, and a new e2e:kubernetes:shared-supervisor-node task.

Release Notes

Kubernetes deployments can run one shared supervisor per node with supervisor.topology: node. When upgrading a gateway-topology deployment, set supervisor.requireIdentityToken=true only after every supervisor has rolled to the new version.

Testing

  • Checks appropriate to the affected code and behavior pass (clippy, rustfmt, workspace unit tests for the changed crates, Helm unit tests, gateway config parser check)
  • Unit tests added/updated
  • E2E tests added/updated: new node topology suite. On images built from this branch, every suite passed conformance (77/77) and its own tests: node topology (9/9), gateway topology (1/1), scaling (8/8), SPIFFE (8/8), and SPIFFE node-local (8/8). The HA suite passed 10/10 after locally adding a missing kubectl_json import that breaks the HA test build on main as well; that fix is tracked separately.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

Record the per-node model as the next one after the per-gateway model.
Each shared supervisor proves its Pod with a pod-bound token, a per-node
supervisor can claim only its own node's member ID, and a per-node
sandbox never falls back to a supervisor on another node.

Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
All shared supervisor Pods present the same gateway-minted supervisor token,
so anyone holding a copy of the token Secret could attach as a supervisor.
The gateway now accepts the supervisor token only beside a projected
ServiceAccount token (audience openshell-supervisor) that TokenReview and a
live-Pod check resolve to a Pod of shared_supervisor.service_account_name.

- shared_supervisor.service_account_name is required; the driver registers
  it with the controller, and the gateway refuses to start the topology
  without it.
- The supervisor sends the token from --identity-token-file in the
  x-openshell-host-identity-token header, re-read on every attempt.
- Helm renders the supervisor ServiceAccount without RBAC, runs the
  supervisor as it, and mounts a 10-minute projected token.

Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Accept supervisor_topology = "node". The gateway records the node that a
supervisor's pod identity token proves on HostIdentity, and in the node
topology the driver binds pool members to nodes, so the gateway refuses
host streams whose pool member ID is not that node. Launches stay refused
until node-local placement lands.

Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
Carry the pool member through SharedSupervision::launch,
PlacementRequest, the stored assignment record, and recovery, and
restrict launch, takeover, and unowned placement of a pinned instance to
that member. With members bound to nodes, the pool never places an
unpinned instance: one launched under the gateway topology stays where
it is until the recovery timeout ends it.

In the node topology the Kubernetes driver ungates the workload Pod,
waits for the scheduler to bind it, launches on that node's supervisor,
records the member on the Sandbox resource for recovery, and creates the
bootstrap Secret last. Supervisors started with --node-supervisor
(OPENSHELL_SUPERVISOR_NODE) no longer leave the pool on shutdown, and a
suspended generation forgets its member.

Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
With supervisor_topology = "node", the chart renders the supervisor as a
DaemonSet on every node, started with --node-supervisor and with the
node name as each Pod's pool member ID. The Service keeps runtimes on
their own node with internalTrafficPolicy: Local, and the node topology
renders no PodDisruptionBudget or HPA. supervisor.tolerations and
supervisor.nodeSelector place supervisors on tainted or selected sandbox
nodes, such as GPU nodes.

Adds the e2e:kubernetes:shared-supervisor-node task on a two-node k3d
cluster, and documents the topology, its platform preconditions, and
that switching topologies ends running shared sandboxes.

Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
With supervisor_topology = "node", create and restart now return after
the driver removes the scheduling gate. The bootstrap launches on the
node once the scheduler binds the workload Pod, and a failed launch or a
Pod that isn't scheduled within runtime_bootstrap_grace_seconds is
logged and rolls the bootstrap back like any stale bootstrap.

A shared supervisor now marks its boundary as stopping on every
requested stop, so stopping a workload that is already gone no longer
waits for a reconnect to time out and stall later instance removals.

Update the Kubernetes HA docs, the driver README, and the
debug-openshell-cluster skill to match.

Signed-off-by: Gal Zaidman <gzaidman@nvidia.com>
@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 29, 2026
@Gal-Zaidman

Copy link
Copy Markdown
Contributor Author

@FrostGod can you please review?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(k8s): run one shared supervisor per node

1 participant