Skip to content

Commit c9370be

Browse files
committed
feat(helm): run the shared supervisor as a per-node DaemonSet
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>
1 parent 1986b11 commit c9370be

22 files changed

Lines changed: 740 additions & 47 deletions

File tree

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ shared process namespace. The sidecar sends SIGKILL to the supervisor as the
143143
same UID; it needs no host PID namespace, capabilities, or runtime socket.
144144
The default k3d/kind test continues to kill through the node container runtime.
145145

146+
`mise run e2e:kubernetes:shared-supervisor-node` runs the
147+
`supervisor_topology: node` e2e (`ci/values-supervisor-node.yaml`) on a
148+
two-node k3d cluster.
149+
146150
### Shared supervisor high availability
147151

148152
`mise run e2e:kubernetes:shared-supervisor-spiffe-node-local` validates direct

‎.config/nextest.toml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test-group = "kubernetes-ha"
3232
# they kill members or gateways, or scale the pool. Never run them at once.
3333
# Test names, not binary(), for the reason above.
3434
[[profile.e2e-kubernetes.overrides]]
35-
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)$/)"
35+
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)$/)"
3636
test-group = "kubernetes-shared-supervisor-pool"
3737

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

62+
# Restarting a node supervisor waits for its replacement to receive the
63+
# supervisor token, attach, and re-adopt the node's instances.
64+
[[profile.e2e-kubernetes.overrides]]
65+
filter = "test(/^each_workload_is_served_by_its_own_nodes_supervisor$/)"
66+
slow-timeout = { period = "60s", terminate-after = 12 }
67+
6268
# Relative to the profile store dir (`e2e/rust/target/nextest/e2e-kubernetes/`).
6369
[profile.e2e-kubernetes.junit]
6470
path = "../../../../../results/e2e-kubernetes.xml"

‎crates/openshell-supervisor/src/shared_host.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ async fn run_stream(
15771577
let mut inbound = match opened {
15781578
Ok(inbound) => inbound,
15791579
Err(error) => {
1580-
tracing::warn!(%error, "could not open the supervisor host stream");
1580+
tracing::warn!("could not open the supervisor host stream: {error}");
15811581
return lost(false);
15821582
}
15831583
};
@@ -1606,7 +1606,7 @@ async fn run_stream(
16061606
let payload = match message {
16071607
Some(Ok(message)) => message.payload,
16081608
Some(Err(status)) => {
1609-
tracing::warn!(%status, "gateway assignment stream failed");
1609+
tracing::warn!("gateway assignment stream failed: {status}");
16101610
break lost(accepted);
16111611
}
16121612
None => break lost(accepted),

‎deploy/helm/openshell/README.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ explicitly. Existing sandboxes stay on their owners when scaling up, and
522522
memory-based scaling does not guarantee spare capacity for handoff. See the
523523
[shared supervisor autoscaling guide](https://docs.nvidia.com/openshell/latest/kubernetes/high-availability#autoscale-shared-supervisors-by-memory).
524524

525+
Set `supervisor_topology: node` in `gatewayConfig.openshell.drivers.kubernetes`
526+
to run one shared supervisor per node as a DaemonSet. See the
527+
[per-node supervisor guide](https://docs.nvidia.com/openshell/latest/kubernetes/high-availability#run-one-supervisor-per-node).
528+
525529
## Secure metrics scraping
526530

527531
Metrics are enabled by default on `service.metricsPort: 9090`. Set
@@ -820,7 +824,7 @@ for peer identity policies, multi-node registrations, and authorization.
820824
| serviceAccount.create | bool | `true` | Create a service account for the gateway. |
821825
| serviceAccount.name | string | `""` | Existing service account name to use when serviceAccount.create is false. |
822826
| storageClass.preflight.enabled | bool | `false` | On a fresh StatefulSet install with no server.dataStorageClass, check for a default StorageClass. The Helm identity must be allowed to list StorageClasses. |
823-
| supervisor.affinity | object | `{}` | Affinity rules for the shared supervisor pod, rendered only when gatewayConfig selects supervisor_topology = "gateway". Top-level affinity applies only to the gateway pod. |
827+
| supervisor.affinity | object | `{}` | Affinity rules for the shared supervisor pod, rendered only when gatewayConfig selects supervisor_topology = "gateway" or "node". Top-level affinity applies only to the gateway pod. |
824828
| supervisor.autoscaling.behavior | object | `{"scaleDown":{"policies":[{"periodSeconds":120,"type":"Pods","value":1}],"stabilizationWindowSeconds":300}}` | HPA scaling behavior. Remove at most one member every two minutes, after a five-minute stabilization window, to allow ownership handoff. |
825829
| supervisor.autoscaling.enabled | bool | `false` | Enable memory-based autoscaling of the shared supervisor Deployment. Requires supervisor_topology = "gateway" and the Kubernetes resource metrics API (usually Metrics Server). When enabled, the HPA owns the replica count and supervisor.replicas is ignored. |
826830
| supervisor.autoscaling.maxReplicas | int | `4` | Maximum supervisor replicas. Must not exceed the gateway replica count * supervisor.pool.maxMembersPerGateway. |
@@ -833,19 +837,21 @@ for peer identity policies, multi-node registrations, and authorization.
833837
| supervisor.image.tag | string | `""` | Supervisor image tag. Defaults to the chart appVersion when empty. |
834838
| supervisor.listenAddress | string | `"0.0.0.0"` | Shared supervisor listener IP. Use `::` for IPv6. |
835839
| supervisor.network.additionalCaConfigMapName | string | `""` | Name of an operator-owned ConfigMap with a `ca.crt` key containing additional destination CA certificates for sandbox supervisors. Empty disables additional destination trust. |
840+
| supervisor.nodeSelector | object | `{}` | Node selector for the shared supervisor pod. With supervisor_topology = "node", it must cover every node that can host sandboxes. |
836841
| supervisor.podDisruptionBudget.enabled | bool | `true` | Render a PodDisruptionBudget with maxUnavailable 1 for the shared supervisor, used only when gatewayConfig selects supervisor_topology = "gateway". Disable it only when maintenance must evict more than one supervisor Pod at a time, or evict a member while another is unavailable. |
837842
| supervisor.podSecurityContext.fsGroup | int | `65534` | fsGroup assigned to the shared supervisor pod. |
838843
| supervisor.podSecurityContext.runAsGroup | int | `65534` | Primary GID assigned to the shared supervisor pod. |
839844
| supervisor.podSecurityContext.runAsNonRoot | bool | `true` | Require the shared supervisor to run as a non-root user. |
840845
| supervisor.podSecurityContext.runAsUser | int | `65534` | UID assigned to the shared supervisor pod. |
841846
| supervisor.podSecurityContext.seccompProfile.type | string | `"RuntimeDefault"` | Seccomp profile applied to the shared supervisor pod. |
842-
| supervisor.pool.maxInstancesPerMember | int | `128` | Most sandboxes one supervisor runs, rendered as [openshell.gateway.supervisor_pool] max_instances_per_member and passed to each supervisor. Must be an integer from 1 to 1024. The gateway refuses a sandbox when every supervisor is full. |
847+
| supervisor.pool.maxInstancesPerMember | int | `128` | Most sandboxes one supervisor runs, rendered as [openshell.gateway.supervisor_pool] max_instances_per_member and passed to each supervisor. Must be an integer from 1 to 1024. The gateway refuses a sandbox when every supervisor is full. Ignored with supervisor_topology = "node", which uses 1024. |
843848
| supervisor.pool.maxMembersPerGateway | int | `32` | Most supervisors one gateway replica serves, rendered as [openshell.gateway.supervisor_pool] max_members_per_gateway. Must be a positive integer. The pool runs at most gateway replicas times maxMembersPerGateway times maxInstancesPerMember sandboxes, never more than 131072. |
844849
| supervisor.recoveryTimeoutSeconds | int | `60` | Seconds a sandbox workload stays frozen after losing its pool member's supervision before the sandbox runtime terminates it, rendered as [openshell.gateway.supervisor_pool] recovery_timeout_secs. Must be an integer from 30 to 300. Null leaves the gateway's pool default of 60 seconds. |
845-
| supervisor.replicas | int | `1` | Shared supervisor pool members, used only when gatewayConfig selects supervisor_topology = "gateway". The gateway always coordinates the shared supervisor as a high-availability pool: when a member fails or leaves, another member takes over its sandboxes without restarting their workloads. 1 has no failover; use 2 or more to survive losing a member. Only the supervisor Deployment's replica count depends on this value, so changing it neither restarts the gateway nor replaces running members. Ignored when supervisor.autoscaling.enabled is true. Must not exceed replicaCount * supervisor.pool.maxMembersPerGateway. |
850+
| supervisor.replicas | int | `1` | Shared supervisor pool members, used only when gatewayConfig selects supervisor_topology = "gateway". The gateway always coordinates the shared supervisor as a high-availability pool: when a member fails or leaves, another member takes over its sandboxes without restarting their workloads. 1 has no failover; use 2 or more to survive losing a member. Only the supervisor Deployment's replica count depends on this value, so changing it neither restarts the gateway nor replaces running members. Ignored when supervisor.autoscaling.enabled is true or supervisor_topology = "node". Must not exceed replicaCount * supervisor.pool.maxMembersPerGateway. |
846851
| supervisor.requireIdentityToken | bool | `false` | Refuse gateway-topology supervisors that attach without their pod-bound identity token. Node-topology supervisors always need it. Refer to the High Availability guide before enabling it on an upgrade. |
847852
| supervisor.resources | object | `{"limits":{"cpu":"1","memory":"1.5Gi"},"requests":{"cpu":"250m","memory":"768Mi"}}` | Resources of each shared supervisor container, initially sized for 128 sandboxes. Increase these with pool.maxInstancesPerMember and allow for failover. Refer to Size Sandbox Capacity in the High Availability guide. Set resources to null to omit the budget, or limits to null to omit limits. |
848853
| supervisor.sandboxRuntime.boundaryPort | int | `5500` | Workload boundary TLS listener port. |
854+
| supervisor.tolerations | list | `[]` | Tolerations for the shared supervisor pod. With supervisor_topology = "node", tolerate every taint a sandbox template tolerates, such as `nvidia.com/gpu` on GPU nodes. |
849855
| tolerations | list | `[]` | Tolerations for the gateway pod. |
850856
| topologySpreadConstraints | list | `[]` | Topology spread constraints for the gateway pod, used to spread replicas across zones or nodes. Empty = omit the field. |
851857
| upstreamProxy | object | `{"authAllowInsecure":false,"authSecret":{"key":"","name":""},"caBundle":{"configMapName":"","key":"ca.crt"},"connectByHostname":false,"noProxy":"","url":""}` | Operator-owned corporate forward proxy for policy-approved TLS egress from Kubernetes sandboxes. The workload cannot select or override it. |

‎deploy/helm/openshell/README.md.gotmpl‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ explicitly. Existing sandboxes stay on their owners when scaling up, and
523523
memory-based scaling does not guarantee spare capacity for handoff. See the
524524
[shared supervisor autoscaling guide](https://docs.nvidia.com/openshell/latest/kubernetes/high-availability#autoscale-shared-supervisors-by-memory).
525525

526+
Set `supervisor_topology: node` in `gatewayConfig.openshell.drivers.kubernetes`
527+
to run one shared supervisor per node as a DaemonSet. See the
528+
[per-node supervisor guide](https://docs.nvidia.com/openshell/latest/kubernetes/high-availability#run-one-supervisor-per-node).
529+
526530
## Secure metrics scraping
527531

528532
Metrics are enabled by default on `service.metricsPort: 9090`. Set
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# E2E overlay: supervise new sandbox generations with one shared supervisor per
5+
# node. Each generation is pinned to the supervisor on its workload's node.
6+
gatewayConfig:
7+
openshell.drivers.kubernetes:
8+
supervisor_topology: node
9+
10+
supervisor:
11+
recoveryTimeoutSeconds: 60

‎deploy/helm/openshell/templates/_helpers.tpl‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,21 @@ flag — so the default value works for any release name or namespace without
359359
override.
360360
*/}}
361361
{{/*
362-
Whether the gateway supervisor topology is enabled. Read from the
363-
raw gateway configuration so openshell.effectiveKubernetesConfig can use it.
362+
Whether a shared supervisor topology (gateway or node) is enabled. Read from
363+
the raw gateway configuration so openshell.effectiveKubernetesConfig can use it.
364364
*/}}
365365
{{- define "openshell.supervisorEnabled" -}}
366366
{{- $kubernetes := get (.Values.gatewayConfig | default dict) "openshell.drivers.kubernetes" | default dict -}}
367-
{{- if eq (get $kubernetes "supervisor_topology" | default "") "gateway" -}}true{{- end -}}
367+
{{- if has (get $kubernetes "supervisor_topology" | default "") (list "gateway" "node") -}}true{{- end -}}
368+
{{- end }}
369+
370+
{{/*
371+
Whether the shared supervisor runs one Pod per node (a DaemonSet) instead of a
372+
replicated Deployment.
373+
*/}}
374+
{{- define "openshell.supervisorNodeTopology" -}}
375+
{{- $kubernetes := get (.Values.gatewayConfig | default dict) "openshell.drivers.kubernetes" | default dict -}}
376+
{{- if eq (get $kubernetes "supervisor_topology" | default "") "node" -}}true{{- end -}}
368377
{{- end }}
369378

370379
{{/*
@@ -514,9 +523,17 @@ key, default, and optionally max.
514523
{{- end -}}
515524
{{- end }}
516525

517-
{{/* Most sandboxes one supervisor runs (supervisor.pool.maxInstancesPerMember). */}}
526+
{{/*
527+
Most sandboxes one supervisor runs (supervisor.pool.maxInstancesPerMember).
528+
A node supervisor takes every sandbox the kubelet admits on its node, so the
529+
node topology always uses the largest cap.
530+
*/}}
518531
{{- define "openshell.supervisorMaxInstancesPerMember" -}}
532+
{{- if include "openshell.supervisorNodeTopology" . -}}
533+
1024
534+
{{- else -}}
519535
{{- include "openshell.supervisorPoolLimit" (dict "root" . "key" "maxInstancesPerMember" "max" 1024 "default" 128) -}}
536+
{{- end -}}
520537
{{- end }}
521538

522539
{{/* Most supervisors one gateway replica serves (supervisor.pool.maxMembersPerGateway). */}}
@@ -563,7 +580,9 @@ TOML form.
563580
{{- fail "supervisor_pool is rendered by the chart; set supervisor.replicas, supervisor.pool, and supervisor.recoveryTimeoutSeconds" -}}
564581
{{- end -}}
565582
{{- if include "openshell.supervisorEnabled" . -}}
583+
{{- if not (include "openshell.supervisorNodeTopology" .) -}}
566584
{{- include "openshell.validateSupervisorMembers" . -}}
585+
{{- end -}}
567586
{{- $table := dict "max_instances_per_member" (int64 (include "openshell.supervisorMaxInstancesPerMember" .)) "max_members_per_gateway" (int64 (include "openshell.supervisorMaxMembersPerGateway" .)) -}}
568587
{{- $recoveryTimeout := include "openshell.supervisorRecoveryTimeoutSeconds" . -}}
569588
{{- if $recoveryTimeout -}}
@@ -845,8 +864,8 @@ Validate chart values that Helm would otherwise accept silently.
845864
{{- $kubernetes := include "openshell.effectiveKubernetesConfig" . | fromYaml -}}
846865
{{- if hasKey $kubernetes "supervisor_topology" -}}
847866
{{- $topology := get $kubernetes "supervisor_topology" -}}
848-
{{- if not (has $topology (list "gateway" "workspace")) -}}
849-
{{- fail "supervisor_topology must be gateway or workspace; omit it to disable the shared supervisor" -}}
867+
{{- if not (has $topology (list "gateway" "node" "workspace")) -}}
868+
{{- fail "supervisor_topology must be gateway, node, or workspace; omit it to disable the shared supervisor" -}}
850869
{{- end -}}
851870
{{- if eq $topology "workspace" -}}
852871
{{- fail "supervisor_topology=workspace is not implemented" -}}
@@ -856,22 +875,22 @@ Validate chart values that Helm would otherwise accept silently.
856875
{{- fail "supervisor_topology requires the kubernetes compute driver" -}}
857876
{{- end -}}
858877
{{- if or (get $kubernetes "https_proxy") (get $kubernetes "proxy_ca_bundle") (get $kubernetes "proxy_auth_secret_name") -}}
859-
{{- fail "supervisor_topology=gateway does not support upstream proxy settings" -}}
878+
{{- fail (printf "supervisor_topology=%s does not support upstream proxy settings" $topology) -}}
860879
{{- end -}}
861880
{{- if .Values.server.disableTls -}}
862-
{{- fail "supervisor_topology=gateway requires gateway TLS; the supervisor token travels only over TLS" -}}
881+
{{- fail (printf "supervisor_topology=%s requires gateway TLS; the supervisor token travels only over TLS" $topology) -}}
863882
{{- end -}}
864883
{{- if and (eq (get $kubernetes "workspace_mode" | default "shared") "operator") (not (regexMatch "^[A-Za-z0-9][-A-Za-z0-9_./]*==?[-A-Za-z0-9_.]*$" (get $kubernetes "operator_namespace_label" | default ""))) -}}
865-
{{- fail "supervisor_topology=gateway in operator workspace mode requires operator_namespace_label of the form key=value" -}}
884+
{{- fail (printf "supervisor_topology=%s in operator workspace mode requires operator_namespace_label of the form key=value" $topology) -}}
866885
{{- end -}}
867886
{{- end -}}
868887
{{- $broker := get (.Values.gatewayConfig | default dict) "openshell.gateway.spiffe_broker" | default dict -}}
869-
{{- if and (eq (get $kubernetes "supervisor_topology" | default "") "gateway") (get $kubernetes "provider_spiffe_workload_api_socket_path") (empty $broker) -}}
888+
{{- if and (include "openshell.supervisorEnabled" .) (get $kubernetes "provider_spiffe_workload_api_socket_path") (empty $broker) -}}
870889
{{- fail "shared supervisor SPIFFE grants require spiffe_broker; remove provider_spiffe_workload_api_socket_path from the shared supervisor" -}}
871890
{{- end -}}
872891
{{- if $broker -}}
873-
{{- if ne (get $kubernetes "supervisor_topology" | default "") "gateway" -}}
874-
{{- fail "spiffe_broker requires supervisor_topology=gateway" -}}
892+
{{- if not (include "openshell.supervisorEnabled" .) -}}
893+
{{- fail "spiffe_broker requires supervisor_topology=gateway or node" -}}
875894
{{- end -}}
876895
{{- include "openshell.validateSpiffeBroker" (dict "broker" $broker) -}}
877896
{{- end -}}

‎deploy/helm/openshell/templates/_supervisor-autoscaling.tpl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{{- fail "supervisor.autoscaling.enabled must be a boolean" -}}
1717
{{- end -}}
1818
{{- if eq (include "openshell.supervisorAutoscalingEnabled" .) "true" -}}
19-
{{- if not (include "openshell.supervisorEnabled" .) -}}
19+
{{- if or (not (include "openshell.supervisorEnabled" .)) (include "openshell.supervisorNodeTopology" .) -}}
2020
{{- fail "supervisor.autoscaling.enabled requires supervisor_topology = gateway" -}}
2121
{{- end -}}
2222
{{- $min := include "openshell.wholeNumber" (get $a "minReplicas") -}}

‎deploy/helm/openshell/templates/supervisor-pdb.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
{{- include "openshell.validateValues" . }}
4-
{{- if and (include "openshell.supervisorEnabled" .) (eq (include "openshell.supervisorPodDisruptionBudgetEnabled" .) "true") }}
4+
{{- if and (include "openshell.supervisorEnabled" .) (not (include "openshell.supervisorNodeTopology" .)) (eq (include "openshell.supervisorPodDisruptionBudgetEnabled" .) "true") }}
55
# Voluntary disruptions, such as node drains, evict one member at a time, so
66
# the remaining members can take over its instances.
77
apiVersion: policy/v1

‎deploy/helm/openshell/templates/supervisor-service.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ metadata:
1313
{{- include "openshell.labels" . | nindent 4 }}
1414
app.kubernetes.io/component: supervisor
1515
spec:
16+
{{- if include "openshell.supervisorNodeTopology" . }}
17+
# A runtime that dials the Service reaches its own node's supervisor.
18+
internalTrafficPolicy: Local
19+
{{- end }}
1620
selector:
1721
{{- include "openshell.supervisorSelectorLabels" . | nindent 4 }}
1822
ports:

0 commit comments

Comments
 (0)