Skip to content

Commit 72ab4dd

Browse files
authored
feat(kubernetes): deploy shared supervisor mode (#4695)
* feat(kubernetes): bootstrap experimental gateway supervisor topology Signed-off-by: Drew Newberry <anewberry@nvidia.com> * docs: move the experimental supervisor topology under an Experimental section Signed-off-by: Drew Newberry <anewberry@nvidia.com> * feat(supervisor): report experimental bootstrap health over TCP experimental-bootstrap now takes --health-port instead of a Unix health socket. It binds the dedicated supervisor's wildcard readiness listener, reachable at the Pod IP, and accepts and closes connections while the process runs. The chart probes the named container port health (5502) with native kubelet tcpSocket checks and drops the health-only emptyDir. No filesystem state remains to clean up after an unclean exit. Dedicated supervisors keep --health-socket-path and health --socket. Signed-off-by: Drew Newberry <anewberry@nvidia.com> * docs: defer public experimental supervisor docs Remove the experimental supervisor topology additions from the published gateway configuration page and the public debug-openshell-cluster skill. Public documentation will be added once the experimental stack settles. Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(supervisor): replace bootstrap with shared host stub Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(supervisor): name shared supervisor subcommand shared Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(supervisor): select shared mode with explicit endpoint flags Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(supervisor): name the shared host module after its mode Rename the shared-mode host module from experimental to shared to match the --mode=shared flag. No behavior changes. Signed-off-by: Drew Newberry <anewberry@nvidia.com> * refactor(kubernetes): drop the experimental prefix from the supervisor topology Rename the Helm template to supervisor.yaml, its Kubernetes names and labels to the -supervisor suffix and supervisor component, and the driver setting to supervisor_topology. The setting remains opt-in and workspace remains reserved. Signed-off-by: Drew Newberry <anewberry@nvidia.com> --------- Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent bd0edb1 commit 72ab4dd

10 files changed

Lines changed: 345 additions & 1 deletion

File tree

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ Override with env vars before running `helm:k3s:create`:
5757
`mcr.microsoft.com/dotnet/aspire-dashboard:latest`)
5858
- `HELM_K3S_COLLECTOR_HEALTH_TIMEOUT` (default: `120` seconds)
5959

60+
### Shared supervisor plumbing
61+
62+
Set `gatewayConfig.openshell.drivers.kubernetes.supervisor_topology`
63+
using a values file (the table key is literally `openshell.drivers.kubernetes`):
64+
65+
```yaml
66+
gatewayConfig:
67+
openshell.drivers.kubernetes:
68+
supervisor_topology: gateway
69+
```
70+
71+
The gateway chart creates a separate, single-replica shared-host placeholder Deployment
72+
in the release namespace, regardless of shared/managed/operator workspace mode.
73+
Use a supervisor image built from this branch: `--mode=shared` is new.
74+
The chart sets `--gateway-endpoint` from the gateway's gRPC endpoint and
75+
`--address` to `0.0.0.0:5501`. Check its rollout and TCP health probes on this
76+
listener (container port `supervisor`, 5501). The outbound gateway connection and
77+
session RPCs are not implemented yet; sandboxes
78+
still use dedicated supervisors. `workspace` is reserved and rejected. Omit the
79+
field to disable it.
80+
6081
### 2. Deploy OpenShell
6182

6283
**Iterative dev** (rebuilds on file changes, recommended during active development):

‎crates/openshell-driver-kubernetes/src/config.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,20 @@ where
194194
Ok(value)
195195
}
196196

197+
/// Scope of a shared supervisor deployment.
198+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
199+
#[serde(rename_all = "snake_case")]
200+
pub enum SupervisorTopology {
201+
Gateway,
202+
Workspace,
203+
}
204+
197205
#[derive(Debug, Clone, Serialize, Deserialize)]
198206
#[serde(default, deny_unknown_fields)]
199207
pub struct KubernetesComputeConfig {
208+
/// Deploy an idle shared supervisor through Helm. Does not route sessions.
209+
#[serde(skip_serializing_if = "Option::is_none")]
210+
pub supervisor_topology: Option<SupervisorTopology>,
200211
/// Permit caller-supplied driver JSON. Does not waive resource admission.
201212
pub allow_driver_config: bool,
202213
/// Operator-owned external attachment approval policy.
@@ -389,6 +400,7 @@ pub const ANNOTATION_SCC_SUPPLEMENTAL_GROUPS: &str = "openshift.io/sa.scc.supple
389400
impl Default for KubernetesComputeConfig {
390401
fn default() -> Self {
391402
Self {
403+
supervisor_topology: None,
392404
workspace_mode: WorkspaceMode::default(),
393405
allow_driver_config: false,
394406
resource_admission:
@@ -442,6 +454,9 @@ impl Default for KubernetesComputeConfig {
442454
impl KubernetesComputeConfig {
443455
/// Validate startup configuration without connecting to Kubernetes.
444456
pub fn validate_configuration(&self) -> Result<(), String> {
457+
if self.supervisor_topology == Some(SupervisorTopology::Workspace) {
458+
return Err("supervisor_topology=workspace is not implemented".into());
459+
}
445460
self.validate_workspace_mode()?;
446461
self.validate_provider_spiffe_workload_api_socket_path()?;
447462
self.validate_sandbox_identity_config()?;

‎crates/openshell-driver-kubernetes/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod sandbox_runtime;
1313
pub use config::{
1414
DEFAULT_GATEWAY_ID, DEFAULT_SANDBOX_SERVICE_ACCOUNT_NAME, DEFAULT_WORKSPACE_STORAGE_SIZE,
1515
KubernetesComputeConfig, KubernetesControlConnection, KubernetesImagePullPolicy,
16-
KubernetesSandboxRuntimeConfig, ManagedSshIngressConfig, WorkspaceMode,
16+
KubernetesSandboxRuntimeConfig, ManagedSshIngressConfig, SupervisorTopology, WorkspaceMode,
1717
managed_namespace_prefix,
1818
};
1919
pub use driver::{KubernetesComputeDriver, KubernetesDriverError};

‎crates/openshell-driver-kubernetes/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ async fn main() -> Result<()> {
260260
let (shutdown_tx, shutdown_rx) = tokio::sync::watch::channel(false);
261261
let driver = KubernetesComputeDriver::new(
262262
KubernetesComputeConfig {
263+
supervisor_topology: None,
263264
allow_driver_config: args.admission_config_json.allow_driver_config,
264265
resource_admission: args.admission_config_json.resource_admission.clone(),
265266
workspace_mode: args.workspace_mode,

‎crates/openshell-supervisor/README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,16 @@ belong to the sandbox or isolation backend. Signals use `BoundarySignal`.
6060

6161
These portable control-plane foundations do not qualify a platform isolation
6262
backend or enable a Windows workload runtime.
63+
64+
## Shared host
65+
66+
`openshell-supervisor --mode=shared --gateway-endpoint https://gateway:8080 --address 0.0.0.0:5501`
67+
starts a shared-host placeholder for the Kubernetes gateway supervisor topology.
68+
The listener at `--address` accepts and closes connections, including kubelet
69+
`tcpSocket` probes, and reports process health only. `--gateway-endpoint` selects
70+
the gateway the supervisor will dial for session control. The outbound connection,
71+
control RPCs, sandbox sessions, gateway authentication, and tenant routing are not
72+
implemented yet. Omitting `--mode` keeps the existing dedicated behavior.
73+
`supervisor_topology = "gateway"` deploys this placeholder; sandboxes
74+
continue using dedicated supervisors. SIGTERM and SIGINT close the listener.
75+
Shared mode is Unix-only.

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,21 @@ use tracing_subscriber::filter::LevelFilter;
1818
use tracing_subscriber::{Layer as _, layer::SubscriberExt as _, util::SubscriberInitExt as _};
1919

2020
mod logging;
21+
mod shared;
2122

2223
const DEBUG_RPC_SUBCOMMAND: &str = "debug-rpc";
2324
const HEALTH_SUBCOMMAND: &str = "health";
2425
const SERVICE_NAME: &str = "openshell-supervisor";
2526

27+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, ValueEnum)]
28+
enum SupervisorMode {
29+
/// Supervise a single sandbox generation.
30+
#[default]
31+
Dedicated,
32+
/// Host sandbox supervision sessions in a shared process.
33+
Shared,
34+
}
35+
2636
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, ValueEnum)]
2737
enum SupervisorRole {
2838
/// Attach an Isolation Backend and supervise one sandbox generation.
@@ -46,6 +56,18 @@ struct HealthArgs {
4656
#[command(about = "OpenShell policy and workload supervisor")]
4757
#[allow(clippy::struct_excessive_bools)]
4858
struct Args {
59+
/// Supervisor deployment mode.
60+
#[arg(long, value_enum, default_value_t)]
61+
mode: SupervisorMode,
62+
63+
/// Gateway endpoint for the shared supervisor's outbound connection.
64+
#[arg(long, required_if_eq("mode", "shared"))]
65+
gateway_endpoint: Option<String>,
66+
67+
/// Shared supervisor listen address, also used for TCP health probes.
68+
#[arg(long, required_if_eq("mode", "shared"))]
69+
address: Option<std::net::SocketAddr>,
70+
4971
/// Supervisor responsibility to run.
5072
#[arg(long, value_enum, default_value_t)]
5173
role: SupervisorRole,
@@ -366,6 +388,21 @@ fn main() -> Result<()> {
366388
}
367389

368390
let args = Args::parse();
391+
if args.mode == SupervisorMode::Shared {
392+
let address = args
393+
.address
394+
.ok_or_else(|| miette::miette!("--address is required for --mode=shared"))?;
395+
let gateway_endpoint = args
396+
.gateway_endpoint
397+
.as_deref()
398+
.ok_or_else(|| miette::miette!("--gateway-endpoint is required for --mode=shared"))?;
399+
return shared::run(address, gateway_endpoint);
400+
}
401+
if args.gateway_endpoint.is_some() || args.address.is_some() {
402+
return Err(miette::miette!(
403+
"--gateway-endpoint and --address require --mode=shared"
404+
));
405+
}
369406
validate_role_arguments(&args)?;
370407
arm_parent_liveness(args.parent_liveness_stdin)?;
371408
validate_main_exit_marker(args.main_exit_marker.as_deref())?;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//! Shared-host placeholder: no sandbox admission, credentials, or session RPCs.
5+
6+
#[cfg(unix)]
7+
use miette::IntoDiagnostic;
8+
use miette::Result;
9+
use std::net::SocketAddr;
10+
11+
// The gateway endpoint is reserved for the shared supervisor's outbound session.
12+
// This plumbing stage only starts the local listener.
13+
pub fn run(address: SocketAddr, _gateway_endpoint: &str) -> Result<()> {
14+
run_platform(address)
15+
}
16+
17+
#[cfg(unix)]
18+
fn run_platform(address: SocketAddr) -> Result<()> {
19+
let runtime = tokio::runtime::Builder::new_current_thread()
20+
.enable_all()
21+
.build()
22+
.into_diagnostic()?;
23+
runtime.block_on(async {
24+
// Install shutdown handlers before publishing health.
25+
let mut terminate =
26+
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
27+
.into_diagnostic()?;
28+
let mut interrupt =
29+
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::interrupt())
30+
.into_diagnostic()?;
31+
let listener = tokio::net::TcpListener::bind(address)
32+
.await
33+
.into_diagnostic()?;
34+
eprintln!(
35+
"Shared supervisor started; gateway connection and sandbox sessions are not implemented"
36+
);
37+
loop {
38+
tokio::select! {
39+
// This placeholder only accepts and closes connections, including
40+
// health probes. Session control will use an outbound gateway stream.
41+
result = listener.accept() => {
42+
if let Err(error) = result {
43+
eprintln!("shared supervisor listener accept failed: {error}");
44+
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
45+
}
46+
}
47+
_ = terminate.recv() => break,
48+
_ = interrupt.recv() => break,
49+
}
50+
}
51+
Ok(())
52+
})
53+
}
54+
55+
#[cfg(not(unix))]
56+
fn run_platform(_address: SocketAddr) -> Result<()> {
57+
Err(miette::miette!("--mode=shared requires Unix"))
58+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,20 @@ like user-supplied schema-v2 fields during compatibility resolution. */}}
568568
Validate chart values that Helm would otherwise accept silently.
569569
*/}}
570570
{{- define "openshell.validateValues" -}}
571+
{{- $kubernetes := include "openshell.effectiveKubernetesConfig" . | fromYaml -}}
572+
{{- if hasKey $kubernetes "supervisor_topology" -}}
573+
{{- $topology := get $kubernetes "supervisor_topology" -}}
574+
{{- if not (has $topology (list "gateway" "workspace")) -}}
575+
{{- fail "supervisor_topology must be gateway or workspace; omit it to disable the shared supervisor" -}}
576+
{{- end -}}
577+
{{- if eq $topology "workspace" -}}
578+
{{- fail "supervisor_topology=workspace is not implemented" -}}
579+
{{- end -}}
580+
{{- $gateway := get (.Values.gatewayConfig | default dict) "openshell.gateway" | default dict -}}
581+
{{- if ne (get $gateway "compute_driver" | default "kubernetes") "kubernetes" -}}
582+
{{- fail "supervisor_topology requires the kubernetes compute driver" -}}
583+
{{- end -}}
584+
{{- end -}}
571585
{{- $workloadKind := include "openshell.workloadKind" . -}}
572586
{{- $workload := .Values.workload | default dict -}}
573587
{{- $maxReplicas := int (include "openshell.maxReplicas" .) -}}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{{- include "openshell.validateValues" . }}
2+
{{- $kubernetes := include "openshell.effectiveKubernetesConfig" . | fromYaml -}}
3+
{{- $imagePullSecrets := get $kubernetes "image_pull_secrets" | default list -}}
4+
{{- range .Values.imagePullSecrets -}}
5+
{{- $imagePullSecrets = append $imagePullSecrets .name -}}
6+
{{- end -}}
7+
{{- if eq (get $kubernetes "supervisor_topology" | default "") "gateway" }}
8+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
9+
# SPDX-License-Identifier: Apache-2.0
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
metadata:
13+
name: {{ include "openshell.fullname" . }}-supervisor
14+
namespace: {{ .Release.Namespace }}
15+
labels:
16+
{{- include "openshell.labels" . | nindent 4 }}
17+
app.kubernetes.io/component: supervisor
18+
spec:
19+
replicas: 1
20+
strategy:
21+
type: Recreate
22+
selector:
23+
matchLabels:
24+
app.kubernetes.io/name: openshell-supervisor
25+
app.kubernetes.io/instance: {{ .Release.Name }}
26+
app.kubernetes.io/component: supervisor
27+
template:
28+
metadata:
29+
labels:
30+
app.kubernetes.io/name: openshell-supervisor
31+
app.kubernetes.io/instance: {{ .Release.Name }}
32+
app.kubernetes.io/component: supervisor
33+
spec:
34+
automountServiceAccountToken: false
35+
terminationGracePeriodSeconds: 30
36+
{{- with ($imagePullSecrets | uniq) }}
37+
imagePullSecrets:
38+
{{- range . }}
39+
- name: {{ . | quote }}
40+
{{- end }}
41+
{{- end }}
42+
securityContext:
43+
runAsNonRoot: true
44+
runAsUser: 65534
45+
runAsGroup: 65534
46+
fsGroup: 65534
47+
seccompProfile:
48+
type: RuntimeDefault
49+
containers:
50+
- name: supervisor
51+
image: {{ get $kubernetes "supervisor_image" | quote }}
52+
imagePullPolicy: {{ get (dict "always" "Always" "if_not_present" "IfNotPresent" "never" "Never") (get $kubernetes "supervisor_image_pull_policy" | default "if_not_present") | quote }}
53+
args:
54+
- --mode=shared
55+
- --gateway-endpoint
56+
- {{ include "openshell.grpcEndpoint" . | quote }}
57+
- --address
58+
- 0.0.0.0:5501
59+
ports:
60+
- name: supervisor
61+
containerPort: 5501
62+
protocol: TCP
63+
securityContext:
64+
allowPrivilegeEscalation: false
65+
readOnlyRootFilesystem: true
66+
capabilities:
67+
drop: [ALL]
68+
resources:
69+
requests:
70+
cpu: 10m
71+
memory: 32Mi
72+
limits:
73+
memory: 128Mi
74+
readinessProbe:
75+
tcpSocket:
76+
port: supervisor
77+
livenessProbe:
78+
tcpSocket:
79+
port: supervisor
80+
{{- end }}

0 commit comments

Comments
 (0)