Skip to content

Commit e671405

Browse files
committed
docs(gateway): add per-driver TOML example configurations
Adds focused single-driver examples next to the comprehensive gateway.example.toml: kubernetes, docker, podman, and microvm. Each one demonstrates the realistic settings for that driver plus how shared [openshell.gateway] defaults inherit into the driver table. A new unit test (`checked_in_examples_parse`) loads every example through the config_file loader so schema drift fails CI rather than silently shipping a broken example.
1 parent 1a81fa2 commit e671405

5 files changed

Lines changed: 145 additions & 0 deletions

File tree

crates/openshell-server/src/config_file.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,4 +515,25 @@ version = 2
515515
.expect_err("missing file must be io error");
516516
assert!(matches!(err, ConfigFileError::Io { .. }));
517517
}
518+
519+
/// Lock in that every checked-in example under `examples/gateway/`
520+
/// round-trips through the loader. Catches schema drift the moment a
521+
/// field is renamed or a doc snippet falls out of date.
522+
#[test]
523+
fn checked_in_examples_parse() {
524+
let repo_root = Path::new(env!("CARGO_MANIFEST_DIR"))
525+
.parent()
526+
.and_then(Path::parent)
527+
.expect("crate manifest has grandparent");
528+
for name in [
529+
"gateway.example.toml",
530+
"kubernetes.example.toml",
531+
"docker.example.toml",
532+
"podman.example.toml",
533+
"microvm.example.toml",
534+
] {
535+
let path = repo_root.join("examples/gateway").join(name);
536+
load(&path).unwrap_or_else(|e| panic!("{name} failed to parse: {e}"));
537+
}
538+
}
518539
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Docker-driver example. Sandboxes run as containers on a local bridge
5+
# network. The supervisor binary is bind-mounted from the host (no in-cluster
6+
# image pull required); guest mTLS material is supplied as host paths.
7+
#
8+
# `database_url` is env-only — set OPENSHELL_DB_URL / --db-url.
9+
10+
[openshell]
11+
version = 1
12+
13+
[openshell.gateway]
14+
bind_address = "127.0.0.1:8080"
15+
log_level = "info"
16+
compute_drivers = ["docker"]
17+
18+
# Shared defaults inherited into [openshell.drivers.docker].
19+
supervisor_image = "ghcr.io/nvidia/openshell/supervisor:latest"
20+
guest_tls_ca = "/etc/openshell/certs/ca.pem"
21+
guest_tls_cert = "/etc/openshell/certs/client.pem"
22+
guest_tls_key = "/etc/openshell/certs/client-key.pem"
23+
24+
[openshell.drivers.docker]
25+
network_name = "openshell-docker"
26+
# Skip the image-pull-and-extract step by pointing at a locally built binary.
27+
supervisor_bin = "/usr/local/libexec/openshell/openshell-sandbox"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Kubernetes-driver example. The gateway runs as a Pod and creates sandbox
5+
# Pods in another namespace. mTLS material for sandboxes is delivered via a
6+
# Kubernetes Secret rather than host-side file paths.
7+
#
8+
# `database_url` is env-only — set OPENSHELL_DB_URL / --db-url.
9+
10+
[openshell]
11+
version = 1
12+
13+
[openshell.gateway]
14+
bind_address = "0.0.0.0:8080"
15+
health_bind_address = "0.0.0.0:8081"
16+
metrics_bind_address = "0.0.0.0:9090"
17+
log_level = "info"
18+
compute_drivers = ["kubernetes"]
19+
20+
# Shared defaults inherited into [openshell.drivers.kubernetes].
21+
default_image = "ghcr.io/nvidia/openshell/sandbox:latest"
22+
supervisor_image = "ghcr.io/nvidia/openshell/supervisor:latest"
23+
image_pull_policy = "IfNotPresent"
24+
client_tls_secret_name = "openshell-client-tls"
25+
26+
[openshell.gateway.tls]
27+
cert_path = "/etc/openshell-tls/server/tls.crt"
28+
key_path = "/etc/openshell-tls/server/tls.key"
29+
client_ca_path = "/etc/openshell-tls/client-ca/ca.crt"
30+
31+
[openshell.drivers.kubernetes]
32+
namespace = "agents"
33+
grpc_endpoint = "https://openshell-gateway.agents.svc:8080"
34+
# Use the image volume on K8s >= 1.35 (GA in 1.36); switch to "init-container"
35+
# on older clusters or where the ImageVolume feature gate is off.
36+
supervisor_sideload_method = "image-volume"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# microVM-driver example. Each sandbox runs inside its own libkrun microVM
5+
# managed by the standalone `openshell-driver-vm` subprocess. Use this driver
6+
# when you want stronger isolation than container namespaces alone.
7+
#
8+
# `database_url` is env-only — set OPENSHELL_DB_URL / --db-url.
9+
10+
[openshell]
11+
version = 1
12+
13+
[openshell.gateway]
14+
bind_address = "127.0.0.1:8080"
15+
log_level = "info"
16+
# VM is never auto-detected; an explicit entry here is required.
17+
compute_drivers = ["vm"]
18+
19+
# Shared defaults inherited into [openshell.drivers.vm].
20+
default_image = "ghcr.io/nvidia/openshell/sandbox:latest"
21+
guest_tls_ca = "/var/lib/openshell/guest-tls/ca.pem"
22+
guest_tls_cert = "/var/lib/openshell/guest-tls/client.pem"
23+
guest_tls_key = "/var/lib/openshell/guest-tls/client-key.pem"
24+
25+
[openshell.drivers.vm]
26+
state_dir = "/var/lib/openshell/vm"
27+
# Where the gateway looks for the openshell-driver-vm subprocess binary.
28+
driver_dir = "/usr/local/libexec/openshell"
29+
vcpus = 2
30+
mem_mib = 2048
31+
krun_log_level = 1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Podman-driver example. Sandboxes run as Podman containers on a user-mode
5+
# bridge network. The supervisor image is mounted read-only via Podman's
6+
# `type=image` mount; guest mTLS material is supplied as host paths.
7+
#
8+
# `database_url` is env-only — set OPENSHELL_DB_URL / --db-url.
9+
10+
[openshell]
11+
version = 1
12+
13+
[openshell.gateway]
14+
bind_address = "127.0.0.1:8080"
15+
log_level = "info"
16+
compute_drivers = ["podman"]
17+
18+
# Shared defaults inherited into [openshell.drivers.podman].
19+
default_image = "ghcr.io/nvidia/openshell/sandbox:latest"
20+
supervisor_image = "ghcr.io/nvidia/openshell/supervisor:latest"
21+
image_pull_policy = "missing" # Podman pull policy: always | missing | never | newer
22+
guest_tls_ca = "/etc/openshell/certs/ca.pem"
23+
guest_tls_cert = "/etc/openshell/certs/client.pem"
24+
guest_tls_key = "/etc/openshell/certs/client-key.pem"
25+
26+
[openshell.drivers.podman]
27+
# Rootless socket path. For root Podman use /run/podman/podman.sock.
28+
socket_path = "/run/user/1000/podman/podman.sock"
29+
network_name = "openshell"
30+
stop_timeout_secs = 10

0 commit comments

Comments
 (0)