Repository navigation
Description
User Story
I run OpenShell on Kubernetes with shared supervisors on a multi-node cluster.
I want each sandbox to be served by the supervisor on its own workload's node, so a failed or compromised node affects only the sandboxes running on it, and a sandbox's runtime traffic to its supervisor doesn't cross nodes.
Problem Statement
The only shared supervisor topology on main is supervisor_topology = "gateway": a pool of supervisor replicas behind one Service, where any replica on any node can be assigned any sandbox. All replicas present the same supervisor token, so the gateway can't tell which node a supervisor runs on, and a sandbox's supervisor is usually on a different node than its workload.
RFC 0018 proposes a per-node model alongside the per-gateway one, and says it will be added when a deployment needs it, behind its own opt-in setting. It doesn't define how a per-node supervisor is bound to a sandbox.
Impact / Why This Matters
With the gateway topology, losing or compromising one supervisor node can affect sandboxes whose workloads run anywhere in the cluster, and every sandbox depends on two nodes. Operators who need node-level isolation have to fall back to dedicated supervisors, which cost one supervisor Pod per sandbox.
Proposed Design
An operator selects supervisor_topology = "node". With it:
- The Helm chart runs the shared supervisor as a DaemonSet, one supervisor per node.
supervisor.nodeSelectorandsupervisor.tolerationsplace supervisors on every node that can host sandboxes, such as tainted GPU nodes. - The Kubernetes scheduler picks the workload's node as today. The sandbox is then served by that node's supervisor at launch and on every takeover, and never falls back to another node's supervisor.
- Each supervisor proves its node to the gateway with a Pod-bound ServiceAccount token, and the gateway accepts a supervisor only for the node its Pod runs on. Shared supervisors in either topology present this token beside the shared supervisor token, so a copy of the token Secret alone no longer attaches a supervisor.
openshell sandbox createreturns once the workload Pod is released to the scheduler. The sandbox launches on its node's supervisor after the Pod is scheduled. A Pod that isn't scheduled in time, or a node without an attached supervisor, fails the sandbox as a stale bootstrap.- When a node's supervisor restarts, that node's sandboxes pause until the replacement attaches within the recovery timeout. A lost node takes its sandboxes with it. There is no cross-node failover.
- The gateway topology's behavior is unchanged, apart from the Pod-bound token.
The node identity relies on Kubernetes keeping a node from obtaining tokens for Pods on other nodes: the API server must run the Node authorizer and the NodeRestriction admission plugin, as most distributions do by default, and only cluster administrators may create Pods with the supervisor ServiceAccount or mint tokens for it.
The PR would record this decision in RFC 0018 as the per-node model, including its threat model.
Suggested UX
gatewayConfig:
openshell.drivers.kubernetes:
supervisor_topology: node
shared_supervisor:
service_account_name: openshell-supervisor
supervisor:
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoScheduleopenshell sandbox create --name agent -- claude
# Returns once the workload Pod is released to the scheduler;
# the sandbox becomes Ready after it launches on that node's supervisor.Acceptance Criteria
- With
supervisor_topology = "node", the chart renders one supervisor per eligible node, with no HPA or PodDisruptionBudget. - A sandbox is served by the supervisor on its workload's node at launch and after a supervisor restart, and never by another node's supervisor.
- The gateway refuses a supervisor whose claimed node differs from the node its Pod-bound token proves, and a shared supervisor without a Pod-bound token.
- A sandbox whose Pod isn't scheduled in time, or whose node has no attached supervisor, fails and rolls back.
- With the gateway topology, sandboxes behave as today, and the existing shared supervisor e2e suites pass.
- A Kubernetes e2e test on a multi-node cluster covers placement on each node and a supervisor restart.
- The docs describe the topology, its cluster requirements, how to place supervisors on tainted nodes, and what happens on a topology switch.
Alternatives Considered
- Dedicated supervisors. They already keep a sandbox's supervisor independent of others, but cost one supervisor Pod per sandbox, which shared supervisors exist to avoid.
- The gateway topology with node affinity. Steering pool replicas toward workload nodes doesn't stop the gateway from assigning a sandbox to any replica, and all replicas still share one identity, so a node can't be isolated.
- Pinning the workload to a node the driver chooses. It would let the driver pick a supervisor first, but it overrides the scheduler and the operator's placement rules. Letting the scheduler choose and binding the supervisor afterwards keeps placement unchanged.
- Cross-node failover. Moving a sandbox to another node's supervisor while its own is down would undo the isolation this topology provides.
Related Work
- Multi-sandbox and HA Supervisors #4311 and RFC 0018: multi-sandbox and HA supervisors; this implements its per-node model.
- feat(kubernetes): operator-set placement for dedicated supervisor pods, and same-node placement with the workload #5547: same-node placement for dedicated supervisors.
Agent Investigation
- The gateway topology's pool lives in
crates/openshell-server/src/supervisor_pool.rs, and the gateway authenticates supervisors incrates/openshell-server/src/auth/supervisor_token.rswith the shared token only. - A prototype exists. It adds the Pod-bound identity, the node topology and node identity, pinning instances to their node's member through launch, takeover, and recovery, the Helm DaemonSet with
internalTrafficPolicy: Local, launch after scheduling, and ane2e:kubernetes:shared-supervisor-nodetask on a two-node k3d cluster.
Checklist
- I've reviewed existing issues and the published docs
- This is a design proposal, not a "please build this" request
Activity