Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b9d8536
docs(rfc): decide the per-node model in RFC 0018
Gal-Zaidman Nov 8, 2026
964f9a3
feat(k8s): require a pod-bound identity for shared supervisors
Gal-Zaidman Nov 22, 2026
3f7b21d
feat(k8s): add the node supervisor topology and node identity
Gal-Zaidman Nov 8, 2026
1e7b22a
feat(k8s): pin node-topology instances to their node supervisor
Gal-Zaidman Nov 8, 2026
fba5d2c
feat(helm): run the shared supervisor as a per-node DaemonSet
Gal-Zaidman Nov 8, 2026
c73fd58
feat(k8s): launch node-topology sandboxes once scheduled
Gal-Zaidman Nov 18, 2026
0bee35d
fix(k8s): keep a stopped sandbox stopped when its deferred launch fin…
Gal-Zaidman Dec 3, 2026
11cedcb
fix(k8s): wait for the node's supervisor before a deferred launch
Gal-Zaidman Dec 3, 2026
db542a4
fix(server): place node-pinned instances only on a supervisor proven …
Gal-Zaidman Dec 3, 2026
857e935
fix(server): end supervisor streams when the Pod identity token expires
Gal-Zaidman Dec 3, 2026
161c7a6
feat(helm): default node supervisors to 300 sandboxes and add rollout…
Gal-Zaidman Dec 3, 2026
ab0a456
docs(kubernetes): document settings for dense sandbox nodes
Gal-Zaidman Dec 3, 2026
c0edf0a
fix(k8s): report why a node-topology create failed before deleting it
Gal-Zaidman Dec 3, 2026
edb5dd7
ci(e2e): run the per-node shared supervisor lane on a multi-node kind…
Gal-Zaidman Dec 3, 2026
0f78e67
docs(kubernetes): note raising the bootstrap grace for autoscaled san…
Gal-Zaidman Dec 4, 2026
564df1c
fix(server): refuse warm pool preparation in the node supervisor topo…
Gal-Zaidman Dec 4, 2026
e505af1
fix(kubernetes): keep gateway-topology shared supervisor config witho…
Gal-Zaidman Dec 4, 2026
788712f
feat(kubernetes): schedule node-topology sandboxes only on nodes runn…
Gal-Zaidman Dec 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .agents/skills/helm-dev-environment/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ shared process namespace. The sidecar sends SIGKILL to the supervisor as the
same UID; it needs no host PID namespace, capabilities, or runtime socket.
The default k3d/kind test continues to kill through the node container runtime.

`mise run e2e:kubernetes:shared-supervisor-node` runs the
`supervisor_topology: node` e2e (`ci/values-supervisor-node.yaml`) on a
two-node k3d cluster.

### Shared supervisor high availability

`mise run e2e:kubernetes:shared-supervisor-spiffe-node-local` validates direct
Expand Down
8 changes: 7 additions & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test-group = "kubernetes-ha"
# they kill members or gateways, or scale the pool. Never run them at once.
# Test names, not binary(), for the reason above.
[[profile.e2e-kubernetes.overrides]]
filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity|supervisors_spread_evenly_across_gateways)$/)"
filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity|supervisors_spread_evenly_across_gateways|each_workload_is_served_by_its_own_nodes_supervisor|a_supervisor_claiming_another_nodes_member_id_is_refused)$/)"
test-group = "kubernetes-shared-supervisor-pool"

# Scaling the pool runs two bounded Helm upgrades (up to 6 minutes each), waits
Expand All @@ -59,6 +59,12 @@ slow-timeout = { period = "60s", terminate-after = 15 }
filter = "test(/^supervisors_spread_evenly_across_gateways$/)"
slow-timeout = { period = "60s", terminate-after = 20 }

# Restarting a node supervisor waits for its replacement to receive the
# supervisor token, attach, and re-adopt the node's instances.
[[profile.e2e-kubernetes.overrides]]
filter = "test(/^each_workload_is_served_by_its_own_nodes_supervisor$/)"
slow-timeout = { period = "60s", terminate-after = 12 }

# Relative to the profile store dir (`e2e/rust/target/nextest/e2e-kubernetes/`).
[profile.e2e-kubernetes.junit]
path = "../../../../../results/e2e-kubernetes.xml"
22 changes: 19 additions & 3 deletions .github/actions/setup-e2e-kind/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ inputs:
description: Replace kindnet with pinned Calico for NetworkPolicy assertions
required: false
default: "false"
worker-nodes:
description: Worker nodes beside the control plane, which kind then taints NoSchedule
required: false
default: "0"

runs:
using: composite
Expand All @@ -46,20 +50,32 @@ runs:
REGISTRY_PASSWORD: ${{ inputs.registry-password }}
run: echo "$REGISTRY_PASSWORD" | docker login "${REGISTRY%%/*}" -u "$REGISTRY_USERNAME" --password-stdin

- name: Configure policy-enforcing kind network
- name: Configure kind cluster
id: kind-config
if: inputs.enforce-network-policy == 'true'
if: inputs.enforce-network-policy == 'true' || inputs.worker-nodes != '0'
shell: bash
env:
ENFORCE_NETWORK_POLICY: ${{ inputs.enforce-network-policy }}
WORKER_NODES: ${{ inputs.worker-nodes }}
run: |
set -euo pipefail
config="$RUNNER_TEMP/kind-network-policy.yaml"
config="$RUNNER_TEMP/kind-config.yaml"
cat > "$config" <<'YAML'
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
YAML
for ((worker = 0; worker < WORKER_NODES; worker++)); do
echo " - role: worker" >> "$config"
done
if [ "$ENFORCE_NETWORK_POLICY" = true ]; then
cat >> "$config" <<'YAML'
networking:
disableDefaultCNI: true
podSubnet: 10.244.0.0/16
YAML
fi
echo "path=$config" >> "$GITHUB_OUTPUT"

# kind comes from mise (pinned in mise.lock) rather than a fresh download.
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/branch-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,22 @@ jobs:
kubernetes-features: e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-ha
use-envoy-gateway: true

kubernetes-shared-supervisor-node-e2e:
needs: [pr_metadata, build-binaries-linux, build-conformance, build-images]
if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_ha_e2e == 'true'
permissions:
actions: read
contents: read
packages: read
uses: ./.github/workflows/e2e-kubernetes-test.yml
with:
checkout-ref: ${{ needs.pr_metadata.outputs.sha }}
prebuilt-conformance: true
image-tag: ${{ needs.pr_metadata.outputs.sha }}
job-name: Kubernetes E2E (shared supervisor per node)
e2e-task: e2e:kubernetes:shared-supervisor-node
worker-nodes: 2

kubernetes-credential-drivers-e2e:
needs: [pr_metadata, build-binaries-linux, build-conformance, build-images]
if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_credential_drivers_e2e == 'true'
Expand Down Expand Up @@ -849,7 +865,7 @@ jobs:

kubernetes-ha-e2e-result:
name: Kubernetes HA E2E result
needs: [pr_metadata, build-binaries-macos, kubernetes-ha-e2e]
needs: [pr_metadata, build-binaries-macos, kubernetes-ha-e2e, kubernetes-shared-supervisor-node-e2e]
if: always() && needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_ha_e2e == 'true'
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/e2e-kubernetes-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ on:
required: false
type: boolean
default: false
worker-nodes:
description: "kind worker nodes beside the control plane"
required: false
type: number
default: 0
listener-topology:
required: false
type: string
Expand Down Expand Up @@ -153,6 +158,7 @@ jobs:
registry-password: ${{ secrets.GITHUB_TOKEN }}
mise-version: ${{ inputs.mise-version }}
enforce-network-policy: ${{ inputs.enforce-network-policy }}
worker-nodes: ${{ inputs.worker-nodes }}

- name: Preload listener workload and client fixture
if: inputs.e2e-task == 'e2e:kubernetes:app-listener'
Expand Down
1 change: 1 addition & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ Available task variants:
| `e2e:kubernetes:shared-supervisor` | One-member shared supervisor pool for the gateway's sandboxes (gateway TLS through the port-forward) |
| `e2e:kubernetes:shared-supervisor-ha` | Two-replica shared supervisor pool behind two gateway replicas on PostgreSQL: kills the member that owns a sandbox and checks the sandbox is adopted, not restarted; crashes and restarts gateways and checks each sandbox's session stays on its supervisor's gateway |
| `e2e:kubernetes:shared-supervisor-scaling` | One-member shared supervisor pool: scales it to two members and back with `helm upgrade`, checking sandboxes stay running and the removed member hands its sandboxes off |
| `e2e:kubernetes:shared-supervisor-node` | One shared supervisor per node on two schedulable nodes: checks each sandbox runs under its node's supervisor, a replaced supervisor re-adopts its node's sandboxes, and a supervisor claiming another node is refused |
| `e2e:kubernetes:tracing` | Deploys a Jaeger collector, exports gateway traces to it, and fails unless Jaeger receives gateway and Kubernetes compute-driver spans for a new sandbox. The only Kubernetes lane that exports traces |

Kubernetes e2e environment variables:
Expand Down
49 changes: 46 additions & 3 deletions crates/openshell-driver-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,15 @@ fails closed.
`shared_supervisor.token_secret_name` Secret in `service_namespace`, which
the supervisor Pod mounts, and names a missing Secret or a denied patch in
the retried error.
- **Pod identity.** The driver registers
`shared_supervisor.service_account_name`, the ServiceAccount the supervisor
Pods run as, with the controller (`require_host_identity`). A projected
ServiceAccount token sent with a supervisor token must resolve to a live Pod
of that account. With `shared_supervisor.require_identity_token`, a
supervisor token without one is refused, so a copy of the token Secret alone
admits no caller. The gateway topology may omit the account, which validation
refuses with the node topology or `require_identity_token`; the gateway then
accepts the supervisor token alone and refuses a projected token.
- **Create and start.** The driver creates a per-sandbox egress allowance
`os-shared-control-<id>` from the workload Pod to the Pods the shared
supervisor's Service selects, on the runtime port, binds its UID and
Expand Down Expand Up @@ -447,9 +456,9 @@ fails closed.
- **Isolation.** The supervisor token is a profile of its own, separate from
every instance's credentials; the gateway refuses it on every other RPC and
refuses every other identity on the assignment stream, and ends a stream
when the token that opened it expires. Sandboxes cannot reach the stream,
and the routing preface only selects which generation-pinned TLS identity
the supervisor demands.
when the token or the Pod identity token that opened it expires. Sandboxes
cannot reach the stream, and the routing preface only selects which
generation-pinned TLS identity the supervisor demands.
- **Workload identity.** The gateway owns SPIFFE Broker API identity acquisition and provider-token
exchange when `openshell.gateway.spiffe_broker` is configured.
Shared supervisors receive final access tokens through their authenticated
Expand All @@ -469,6 +478,40 @@ When the setting is removed, reconciliation suspends shared generations, and a
restart creates the dedicated generation's boundary Service the shared one never
had.

#### Node topology

`supervisor_topology = "node"` runs the same shared pool with one supervisor
per node, and pins each generation to the supervisor on its workload's node.
The driver binds pool members to nodes (`bind_members_to_nodes`): the gateway
accepts a supervisor only when the Pod its identity token resolves to is
scheduled on the node it claims as its pool member ID.

- **Placement.** Each generation's workload Pod requires Pod affinity, on
`kubernetes.io/hostname`, to a Pod the supervisor Service selects in
`service_namespace`, so the scheduler only picks nodes running a supervisor;
a restart outside this topology clears it. The driver removes the
scheduling gate and returns from create or restart before it assigns the
instance. The bootstrap task watches
the workload Pod, waits for the supervisor of the node in its `spec.nodeName`
to join the pool, and launches there. A Pod that is deleted or replaced, or a
node supervisor that refuses the instance, rolls the bootstrap back. So does
a Pod that isn't scheduled, or a node supervisor that doesn't join, within
`runtime_bootstrap_grace_seconds`. A failed create first records its cause
in `openshell.ai/sandbox-runtime-launch-failure`, reported as a terminal
`Ready=False` (`SandboxRuntimeLaunchFailed`), and the reaper deletes it on
its next pass. Each launch write re-checks that the
Sandbox still awaits this launch, so a stop, delete, or newer attempt served
by another gateway replica wins.
The Sandbox's `openshell.ai/sandbox-runtime-supervisor-member` annotation
records the pinned node. The bootstrap Secret exists before the gate is removed; until the
launch places the route, the supervisor refuses the runtime's dials and the
workload does not start.
- **Recovery and takeover.** Recovery reads the member annotation and skips a
node-topology generation that lacks one. Placement, takeover, and recovery
of a pinned instance only consider its own member, so a lost node
supervisor's instances wait for it to return. A restart clears the
annotation, and the new generation records its own node.

## Sandbox Resource

The driver works with the `agents.x-k8s.io` `Sandbox` custom resource. It
Expand Down
100 changes: 92 additions & 8 deletions crates/openshell-driver-kubernetes/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,13 @@ where
#[serde(rename_all = "snake_case")]
pub enum SupervisorTopology {
Gateway,
/// One shared supervisor per node, serving the sandboxes whose workload
/// Pods run on that node.
Node,
Workspace,
}

/// The supervisor Helm deploys for the gateway topology.
/// The supervisor Helm deploys for the gateway or node topology.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SharedSupervisorConfig {
Expand All @@ -236,6 +239,16 @@ pub struct SharedSupervisorConfig {
/// gateway-minted supervisor token (key `token`); the supervisor Pod
/// mounts it and presents the token on its assignment stream.
pub token_secret_name: String,
/// `ServiceAccount` in `service_namespace` the supervisor Pods run as; a
/// pod-bound token for it accompanies the supervisor token. Unset, the
/// gateway topology accepts the supervisor token alone and refuses a
/// pod-bound token it cannot verify.
#[serde(default)]
pub service_account_name: Option<String>,
/// Refuse a supervisor token without the pod-bound token. A present
/// token is verified either way.
#[serde(default)]
pub require_identity_token: bool,
}

impl SharedSupervisorConfig {
Expand All @@ -251,6 +264,15 @@ impl SharedSupervisorConfig {
if !is_dns_subdomain(&self.token_secret_name) {
return Err("shared_supervisor token_secret_name must be a DNS subdomain name".into());
}
if self
.service_account_name
.as_deref()
.is_some_and(|name| !is_dns_subdomain(name))
{
return Err(
"shared_supervisor service_account_name must be a DNS subdomain name".into(),
);
}
Ok(())
}

Expand Down Expand Up @@ -693,18 +715,33 @@ impl KubernetesComputeConfig {
match self.supervisor_topology {
None => {
if self.shared_supervisor.is_some() {
return Err("shared_supervisor requires supervisor_topology=gateway".into());
return Err(
"shared_supervisor requires supervisor_topology=gateway or node".into(),
);
}
Ok(())
}
Some(SupervisorTopology::Workspace) => {
Err("supervisor_topology=workspace is not implemented".into())
}
Some(SupervisorTopology::Gateway) => {
Some(topology @ (SupervisorTopology::Gateway | SupervisorTopology::Node)) => {
let topology_name = if topology == SupervisorTopology::Node {
"node"
} else {
"gateway"
};
let shared = self.shared_supervisor.as_ref().ok_or_else(|| {
"supervisor_topology=gateway requires shared_supervisor".to_string()
format!("supervisor_topology={topology_name} requires shared_supervisor")
})?;
shared.validate()?;
if shared.service_account_name.is_none() {
if topology == SupervisorTopology::Node {
return Err("supervisor_topology=node requires shared_supervisor.service_account_name; the pod-bound token for it proves each supervisor's node".into());
}
if shared.require_identity_token {
return Err("shared_supervisor.require_identity_token requires shared_supervisor.service_account_name".into());
}
}
if self.sandbox_runtime.app_listener.common.enabled
&& self.sandbox_runtime.app_listener.common.port == shared.runtime_port
{
Expand All @@ -714,10 +751,9 @@ impl KubernetesComputeConfig {
|| self.proxy_auth_secret_name.is_some()
|| self.proxy_ca_bundle.is_some()
{
return Err(
"supervisor_topology=gateway does not support upstream proxy settings"
.into(),
);
return Err(format!(
"supervisor_topology={topology_name} does not support upstream proxy settings"
));
}
Ok(())
}
Expand Down Expand Up @@ -1317,6 +1353,8 @@ mod tests {
service_namespace: "openshell".to_string(),
runtime_port: 8443,
token_secret_name: "openshell-supervisor-token".to_string(),
service_account_name: Some("openshell-supervisor".to_string()),
require_identity_token: false,
};
let gateway = |shared: Option<SharedSupervisorConfig>| KubernetesComputeConfig {
supervisor_topology: Some(SupervisorTopology::Gateway),
Expand Down Expand Up @@ -1348,6 +1386,10 @@ mod tests {
token_secret_name: "Not_A_Secret_Name".to_string(),
..shared()
},
SharedSupervisorConfig {
service_account_name: Some("Not_A_Name".to_string()),
..shared()
},
] {
assert!(
gateway(Some(invalid))
Expand All @@ -1373,6 +1415,48 @@ mod tests {
assert!(workspace.validate_supervisor_topology().is_err());
}

#[test]
fn shared_supervisor_account_is_required_only_to_verify_pod_identity() {
let legacy: KubernetesComputeConfig = toml::from_str(
r#"
supervisor_topology = "gateway"

[shared_supervisor]
service_name = "openshell-supervisor"
service_namespace = "openshell"
runtime_port = 5500
token_secret_name = "openshell-supervisor-token"
"#,
)
.expect("a shared_supervisor table without the account parses");
let shared = legacy.shared_supervisor.clone().unwrap();
assert_eq!(shared.service_account_name, None);
assert!(legacy.validate_supervisor_topology().is_ok());

let node = KubernetesComputeConfig {
supervisor_topology: Some(SupervisorTopology::Node),
..legacy.clone()
};
assert!(
node.validate_supervisor_topology()
.unwrap_err()
.contains("service_account_name")
);
let enforced = KubernetesComputeConfig {
shared_supervisor: Some(SharedSupervisorConfig {
require_identity_token: true,
..shared
}),
..legacy
};
assert!(
enforced
.validate_supervisor_topology()
.unwrap_err()
.contains("service_account_name")
);
}

#[test]
fn image_pull_policy_accepts_config_and_kubernetes_spellings() {
for (value, expected) in [
Expand Down
Loading
Loading