Skip to content

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

Backlog

Description

@Gal-Zaidman

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.nodeSelector and supervisor.tolerations place 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 create returns 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: NoSchedule
openshell 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

Agent Investigation

  • The gateway topology's pool lives in crates/openshell-server/src/supervisor_pool.rs, and the gateway authenticates supervisors in crates/openshell-server/src/auth/supervisor_token.rs with 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 an e2e:kubernetes:shared-supervisor-node task 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

  1. added
    state:triage-needed
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions