Skip to content

Commit 6d49eb8

Browse files
committed
refactor(gateway): move driver options into config
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent bbc878b commit 6d49eb8

46 files changed

Lines changed: 657 additions & 1007 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

architecture/gateway.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,21 @@ The gateway reads its configuration from three sources, merged in this
199199
precedence (highest first):
200200

201201
```
202-
CLI flag > OPENSHELL_* env var > TOML file > built-in default
202+
Gateway CLI flag > gateway OPENSHELL_* env var > TOML file > built-in default
203203
```
204204

205205
The TOML file is opt-in via `--config <PATH>` / `OPENSHELL_GATEWAY_CONFIG`.
206-
When unset, the gateway behaves exactly as before — CLI flags and env vars
207-
drive every setting. See `docs/reference/gateway-config.mdx` for worked
208-
per-driver examples and RFC 0003 for the full schema.
206+
Driver implementation settings live in the TOML driver tables. See
207+
`docs/reference/gateway-config.mdx` for worked per-driver examples and RFC
208+
0003 for the full schema.
209209

210210
`database_url` is env-only and rejected when present in the file
211211
(`OPENSHELL_DB_URL` / `--db-url`).
212212

213213
### Driver inheritance
214214

215-
`[openshell.gateway]` carries a small set of values (`default_image`,
215+
`[openshell.gateway]` carries a small set of values (`sandbox_namespace`,
216+
`default_image`,
216217
`supervisor_image`, `guest_tls_ca/cert/key`, `client_tls_secret_name`,
217218
`host_gateway_ip`, `enable_user_namespaces`) that are inherited into each
218219
driver's `[openshell.drivers.<name>]` table when the driver-specific table
@@ -227,8 +228,8 @@ value means the same thing in both, so the key lives only under each
227228
driver's own table.
228229

229230
Driver-specific values that are not part of the inheritance allowlist
230-
(e.g. K8s `namespace`, Podman `socket_path`, VM `vcpus`) only come from
231-
the driver's own table.
231+
(e.g. Podman `socket_path`, VM `vcpus`) only come from the driver's own
232+
table.
232233

233234
## Operational Constraints
234235

crates/openshell-core/src/config.rs

Lines changed: 1 addition & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::str::FromStr;
2121
/// Default SSH port inside sandbox containers.
2222
pub const DEFAULT_SSH_PORT: u16 = 2222;
2323

24-
/// Default server / SSH gateway port.
24+
/// Default gateway server port.
2525
pub const DEFAULT_SERVER_PORT: u16 = 8080;
2626

2727
/// Default container stop timeout in seconds (SIGTERM → SIGKILL).
@@ -216,75 +216,10 @@ pub struct Config {
216216
#[serde(default)]
217217
pub compute_drivers: Vec<ComputeDriverKind>,
218218

219-
/// Kubernetes namespace for sandboxes.
220-
#[serde(default = "default_sandbox_namespace")]
221-
pub sandbox_namespace: String,
222-
223-
/// Default container image for sandboxes.
224-
#[serde(default = "default_sandbox_image")]
225-
pub sandbox_image: String,
226-
227-
/// Kubernetes `imagePullPolicy` for sandbox pods (e.g. `Always`,
228-
/// `IfNotPresent`, `Never`). Defaults to empty, which lets Kubernetes
229-
/// apply its own default (`:latest` → `Always`, anything else →
230-
/// `IfNotPresent`).
231-
#[serde(default)]
232-
pub sandbox_image_pull_policy: String,
233-
234-
/// gRPC endpoint for sandboxes to connect back to `OpenShell`.
235-
/// Used by sandbox pods to fetch their policy at startup.
236-
#[serde(default)]
237-
pub grpc_endpoint: String,
238-
239-
/// Public gateway host for SSH proxy connections.
240-
#[serde(default = "default_ssh_gateway_host")]
241-
pub ssh_gateway_host: String,
242-
243-
/// Public gateway port for SSH proxy connections.
244-
#[serde(default = "default_ssh_gateway_port")]
245-
pub ssh_gateway_port: u16,
246-
247-
/// SSH listen port inside sandbox containers that expose a TCP endpoint.
248-
#[serde(default = "default_sandbox_ssh_port")]
249-
pub sandbox_ssh_port: u16,
250-
251-
/// Filesystem path where the sandbox supervisor binds its SSH Unix
252-
/// socket. The supervisor is passed this path via
253-
/// `OPENSHELL_SSH_SOCKET_PATH` / `--ssh-socket-path` and connects its
254-
/// relay bridge to the same path.
255-
///
256-
/// When the gateway orchestrates sandboxes that each live in their own
257-
/// filesystem (K8s pod, libkrun VM, etc.), the default is safe. For
258-
/// local dev where multiple supervisors share `/run`, override this to
259-
/// something unique per sandbox.
260-
#[serde(default = "default_sandbox_ssh_socket_path")]
261-
pub sandbox_ssh_socket_path: String,
262-
263219
/// TTL for SSH session tokens, in seconds. 0 disables expiry.
264220
#[serde(default = "default_ssh_session_ttl_secs")]
265221
pub ssh_session_ttl_secs: u64,
266222

267-
/// Kubernetes secret name containing client TLS materials for sandbox pods.
268-
/// When set, sandbox pods get this secret mounted so they can connect to
269-
/// the server over mTLS.
270-
#[serde(default)]
271-
pub client_tls_secret_name: String,
272-
273-
/// Host gateway IP for sandbox pod hostAliases.
274-
/// When set, sandbox pods get hostAliases entries mapping
275-
/// `host.docker.internal` and `host.openshell.internal` to this IP,
276-
/// allowing them to reach services running on the Docker host.
277-
#[serde(default)]
278-
pub host_gateway_ip: String,
279-
280-
/// Enable Kubernetes user namespace isolation (`hostUsers: false`) for
281-
/// sandbox pods. When enabled, container UID 0 maps to an unprivileged
282-
/// host UID and capabilities become namespaced. Requires Kubernetes 1.33+
283-
/// with user namespace support available (beta through 1.35, GA in 1.36+),
284-
/// plus a supporting container runtime and Linux 5.12+.
285-
#[serde(default)]
286-
pub enable_user_namespaces: bool,
287-
288223
/// Browser-facing sandbox service routing configuration.
289224
#[serde(default)]
290225
pub service_routing: ServiceRoutingConfig,
@@ -401,18 +336,7 @@ impl Config {
401336
oidc: None,
402337
database_url: String::new(),
403338
compute_drivers: vec![],
404-
sandbox_namespace: default_sandbox_namespace(),
405-
sandbox_image: default_sandbox_image(),
406-
sandbox_image_pull_policy: String::new(),
407-
grpc_endpoint: String::new(),
408-
ssh_gateway_host: default_ssh_gateway_host(),
409-
ssh_gateway_port: default_ssh_gateway_port(),
410-
sandbox_ssh_port: default_sandbox_ssh_port(),
411-
sandbox_ssh_socket_path: default_sandbox_ssh_socket_path(),
412339
ssh_session_ttl_secs: default_ssh_session_ttl_secs(),
413-
client_tls_secret_name: String::new(),
414-
host_gateway_ip: String::new(),
415-
enable_user_namespaces: false,
416340
service_routing: ServiceRoutingConfig::default(),
417341
}
418342
}
@@ -473,76 +397,13 @@ impl Config {
473397
self
474398
}
475399

476-
/// Create a new configuration with a sandbox namespace.
477-
#[must_use]
478-
pub fn with_sandbox_namespace(mut self, namespace: impl Into<String>) -> Self {
479-
self.sandbox_namespace = namespace.into();
480-
self
481-
}
482-
483-
/// Create a new configuration with a default sandbox image.
484-
#[must_use]
485-
pub fn with_sandbox_image(mut self, image: impl Into<String>) -> Self {
486-
self.sandbox_image = image.into();
487-
self
488-
}
489-
490-
/// Create a new configuration with a sandbox image pull policy.
491-
#[must_use]
492-
pub fn with_sandbox_image_pull_policy(mut self, policy: impl Into<String>) -> Self {
493-
self.sandbox_image_pull_policy = policy.into();
494-
self
495-
}
496-
497-
/// Create a new configuration with a gRPC endpoint for sandbox callback.
498-
#[must_use]
499-
pub fn with_grpc_endpoint(mut self, endpoint: impl Into<String>) -> Self {
500-
self.grpc_endpoint = endpoint.into();
501-
self
502-
}
503-
504-
/// Create a new configuration with the SSH gateway host.
505-
#[must_use]
506-
pub fn with_ssh_gateway_host(mut self, host: impl Into<String>) -> Self {
507-
self.ssh_gateway_host = host.into();
508-
self
509-
}
510-
511-
/// Create a new configuration with the SSH gateway port.
512-
#[must_use]
513-
pub const fn with_ssh_gateway_port(mut self, port: u16) -> Self {
514-
self.ssh_gateway_port = port;
515-
self
516-
}
517-
518-
/// Create a new configuration with the sandbox SSH port.
519-
#[must_use]
520-
pub const fn with_sandbox_ssh_port(mut self, port: u16) -> Self {
521-
self.sandbox_ssh_port = port;
522-
self
523-
}
524-
525400
/// Create a new configuration with the SSH session TTL.
526401
#[must_use]
527402
pub const fn with_ssh_session_ttl_secs(mut self, secs: u64) -> Self {
528403
self.ssh_session_ttl_secs = secs;
529404
self
530405
}
531406

532-
/// Set the Kubernetes secret name for sandbox client TLS materials.
533-
#[must_use]
534-
pub fn with_client_tls_secret_name(mut self, name: impl Into<String>) -> Self {
535-
self.client_tls_secret_name = name.into();
536-
self
537-
}
538-
539-
/// Set the host gateway IP for sandbox pod hostAliases.
540-
#[must_use]
541-
pub fn with_host_gateway_ip(mut self, ip: impl Into<String>) -> Self {
542-
self.host_gateway_ip = ip.into();
543-
self
544-
}
545-
546407
/// Set the OIDC configuration for JWT-based authentication.
547408
#[must_use]
548409
pub fn with_oidc(mut self, oidc: OidcConfig) -> Self {
@@ -647,30 +508,6 @@ fn default_log_level() -> String {
647508
"info".to_string()
648509
}
649510

650-
fn default_sandbox_namespace() -> String {
651-
"default".to_string()
652-
}
653-
654-
fn default_sandbox_image() -> String {
655-
format!("{}/base:latest", crate::image::DEFAULT_COMMUNITY_REGISTRY)
656-
}
657-
658-
fn default_ssh_gateway_host() -> String {
659-
"127.0.0.1".to_string()
660-
}
661-
662-
const fn default_ssh_gateway_port() -> u16 {
663-
DEFAULT_SERVER_PORT
664-
}
665-
666-
fn default_sandbox_ssh_socket_path() -> String {
667-
"/run/openshell/ssh.sock".to_string()
668-
}
669-
670-
const fn default_sandbox_ssh_port() -> u16 {
671-
DEFAULT_SSH_PORT
672-
}
673-
674511
const fn default_ssh_session_ttl_secs() -> u64 {
675512
86400 // 24 hours
676513
}

crates/openshell-driver-docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ The agent child process does not retain these supervisor privileges.
3939
The Docker driver bind-mounts a host-side Linux `openshell-sandbox` binary into
4040
each sandbox container. Resolution order is:
4141

42-
1. `--docker-supervisor-bin` / `OPENSHELL_DOCKER_SUPERVISOR_BIN`.
42+
1. `supervisor_bin` in `[openshell.drivers.docker]`.
4343
2. A sibling `openshell-sandbox` next to the running `openshell-gateway` binary.
4444
3. A local Linux cargo target build for the Docker daemon architecture.
45-
4. `--docker-supervisor-image` / `OPENSHELL_DOCKER_SUPERVISOR_IMAGE`, or the
45+
4. `supervisor_image` in `[openshell.drivers.docker]`, or the
4646
release-matched default supervisor image, extracting `/openshell-sandbox`.
4747

4848
Release and Docker-image gateway builds bake the matching supervisor image tag

0 commit comments

Comments
 (0)