Skip to content

Commit d8fc3ab

Browse files
committed
feat(deploy): warm-pool gateway config and least-privilege RBAC
Render warm-pool settings into gateway.toml, add a values-warm-pool.yaml CI overlay, document the fields in the config reference, and grant the gateway only the extension-CRD verbs it uses: server-side apply (create+patch) on templates/pools and create/delete/get/list/watch on claims, with no status subresources. The sandbox pod ServiceAccount is intentionally granted none of these. Signed-off-by: Roshni Malani <rmalani@nvidia.com>
1 parent d390efc commit d8fc3ab

6 files changed

Lines changed: 131 additions & 0 deletions

File tree

‎deploy/helm/openshell/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ add `ci/values-spire.yaml` to the OpenShell release values files.
225225
| server.tls.certSecretName | string | `"openshell-server-tls"` | K8s secret (type kubernetes.io/tls) with tls.crt and tls.key for the server. |
226226
| server.tls.clientCaSecretName | string | `"openshell-server-client-ca"` | K8s secret with ca.crt for client certificate verification (mTLS). Set to "" to disable mTLS and run HTTPS-only (use OIDC for auth instead). |
227227
| server.tls.clientTlsSecretName | string | `"openshell-client-tls"` | K8s secret mounted into sandbox pods for mTLS to the server. |
228+
| server.warmPool.enabled | bool | `false` | Enable warm pooling. Off by default; only the trusted default sandbox image with no per-request template/env overrides is warm-pooled — any other request falls back to the cold create path. |
229+
| server.warmPool.pools | list | `[]` | Operator-declared pools. Each maps to one (image, runtimeClass, gpu) shape. Example: pools: - name: default replicas: 3 - name: gpu replicas: 1 gpu: true runtimeClassName: nvidia # Optional shared, read-only data volume (datasets/models/caches). sharedVolume: claimName: models # existing PVC (ROX/RWX for multi-node) mountPath: /models subPath: "" # optional |
228230
| server.workspaceDefaultStorageSize | string | `""` | Default storage size for the workspace PVC in sandbox pods. Uses Kubernetes quantity syntax (e.g. "2Gi", "10Gi", "500Mi"). Empty = built-in default (2Gi). |
229231
| service.healthPort | int | `8081` | Gateway health service port. |
230232
| service.metricsPort | int | `9090` | Gateway metrics service port. |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Overlay that enables warm-pooled sandboxes for the Kubernetes e2e harness
5+
# (issue #1879). Layer it on top of values-skaffold.yaml, e.g.:
6+
#
7+
# OPENSHELL_E2E_KUBE_EXTRA_VALUES=deploy/helm/openshell/ci/values-warm-pool.yaml \
8+
# OPENSHELL_E2E_WARM_POOL=1 \
9+
# mise run e2e:kubernetes
10+
#
11+
# Requires the agent-sandbox warm-pool extension CRDs (the kube e2e harness
12+
# installs them). A single CPU pool of the trusted default image is enough to
13+
# exercise the claim path and the workspace-isolation assertions.
14+
server:
15+
warmPool:
16+
enabled: true
17+
pools:
18+
- name: default
19+
replicas: 2

‎deploy/helm/openshell/templates/gateway-config.yaml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,21 @@ data:
141141
{{- if .Values.supervisor.image.pullPolicy }}
142142
supervisor_image_pull_policy = {{ .Values.supervisor.image.pullPolicy | quote }}
143143
{{- end }}
144+
{{- if .Values.server.warmPool.enabled }}
145+
146+
[openshell.drivers.kubernetes.warm_pool]
147+
enabled = true
148+
{{- range .Values.server.warmPool.pools }}
149+
150+
[[openshell.drivers.kubernetes.warm_pool.pools]]
151+
name = {{ .name | quote }}
152+
replicas = {{ .replicas }}
153+
gpu = {{ .gpu | default false }}
154+
{{- if .runtimeClassName }}
155+
runtime_class_name = {{ .runtimeClassName | quote }}
156+
{{- end }}
157+
{{- if .sharedVolume }}
158+
shared_volume = { claim_name = {{ .sharedVolume.claimName | quote }}, mount_path = {{ .sharedVolume.mountPath | quote }}{{ if .sharedVolume.subPath }}, sub_path = {{ .sharedVolume.subPath | quote }}{{ end }} }
159+
{{- end }}
160+
{{- end }}
161+
{{- end }}

‎deploy/helm/openshell/templates/role.yaml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@ rules:
2222
- patch
2323
- update
2424
- watch
25+
# Warm-pool extension CRDs (issue #1879). The gateway reconciles the
26+
# operator-owned SandboxTemplate + SandboxWarmPool, creates/deletes a
27+
# SandboxClaim per warm-pooled sandbox, and reads claims during the
28+
# IssueSandboxToken identity re-anchor. The sandbox pod ServiceAccount is a
29+
# separate identity and is intentionally NOT granted any of these — a
30+
# compromised sandbox must not be able to mutate claims, templates, or pools.
31+
#
32+
# Least privilege: only the verbs the gateway actually exercises are granted.
33+
# Templates/pools are reconciled with server-side apply (create + patch only —
34+
# never update/get/list/watch). Claims are created, deleted, read back, and
35+
# watched (create/delete/get/list/watch) — the driver runs a live watcher on
36+
# SandboxClaims to surface warm/claim-bound sandboxes. The gateway never writes
37+
# the controller-owned status subresources, so they are omitted.
38+
- apiGroups:
39+
- extensions.agents.x-k8s.io
40+
resources:
41+
- sandboxtemplates
42+
- sandboxwarmpools
43+
verbs:
44+
- create
45+
- patch
46+
- apiGroups:
47+
- extensions.agents.x-k8s.io
48+
resources:
49+
- sandboxclaims
50+
verbs:
51+
- create
52+
- delete
53+
- get
54+
- list
55+
- watch
2556
- apiGroups:
2657
- ""
2758
resources:

‎deploy/helm/openshell/values.yaml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,30 @@ server:
195195
# Linux 5.12+. When enabled, container UID 0 maps to an unprivileged host
196196
# UID and capabilities become namespaced.
197197
enableUserNamespaces: false
198+
# Warm-pooled sandboxes (issue #1879). The gateway pre-declares operator-owned
199+
# SandboxWarmPools and satisfies matching CreateSandbox requests by binding a
200+
# pre-warmed pod (~0.1s) instead of cold-creating one (~4s+). Requires the
201+
# agent-sandbox warm-pool extension CRDs installed in the cluster.
202+
warmPool:
203+
# -- Enable warm pooling. Off by default; only the trusted default sandbox
204+
# image with no per-request template/env overrides is warm-pooled — any
205+
# other request falls back to the cold create path.
206+
enabled: false
207+
# -- Operator-declared pools. Each maps to one (image, runtimeClass, gpu)
208+
# shape. Example:
209+
# pools:
210+
# - name: default
211+
# replicas: 3
212+
# - name: gpu
213+
# replicas: 1
214+
# gpu: true
215+
# runtimeClassName: nvidia
216+
# # Optional shared, read-only data volume (datasets/models/caches).
217+
# sharedVolume:
218+
# claimName: models # existing PVC (ROX/RWX for multi-node)
219+
# mountPath: /models
220+
# subPath: "" # optional
221+
pools: []
198222
# -- Kubernetes AppArmor profile requested for sandbox agent containers.
199223
# Default Unconfined avoids runtime/default AppArmor blocking the supervisor's
200224
# network namespace mount setup on AppArmor-enabled nodes. Set to "" to omit

‎docs/reference/gateway-config.mdx‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,50 @@ workspace_default_storage_size = "10Gi"
189189
# default_runtime_class_name = "kata-containers"
190190
# Kubelet clamps projected tokens below 600 seconds. The driver caps values at 86400.
191191
sa_token_ttl_secs = 3600
192+
192193
# Optional SPIFFE Workload API socket mounted into sandbox pods for dynamic
193194
# provider token grants. Use an absolute path under a dedicated directory;
194195
# shared roots such as /run, /var, /tmp, and /etc are rejected.
195196
# Supervisor-to-gateway auth still uses gateway JWTs.
196197
provider_spiffe_workload_api_socket_path = "/spiffe-workload-api/spire-agent.sock"
198+
199+
# Warm-pooled sandboxes (optional). When enabled, the gateway pre-declares
200+
# operator-owned SandboxWarmPools and satisfies matching CreateSandbox requests
201+
# by binding a pre-warmed pod (~0.1s) instead of cold-creating one. Requires the
202+
# agent-sandbox warm-pool extension CRDs installed in the cluster. Only the
203+
# trusted default image with no per-request template/env overrides is pooled;
204+
# anything else falls back to the cold path.
205+
[openshell.drivers.kubernetes.warm_pool]
206+
enabled = true
207+
208+
[[openshell.drivers.kubernetes.warm_pool.pools]]
209+
name = "default"
210+
replicas = 3
211+
212+
[[openshell.drivers.kubernetes.warm_pool.pools]]
213+
name = "gpu"
214+
replicas = 1
215+
gpu = true
216+
runtime_class_name = "nvidia"
217+
# Optional shared, read-only data volume (datasets / models / caches). Mounted
218+
# read-only into every pooled pod; safe to share because it holds no per-agent
219+
# state. The PVC must support a read-many access mode (ROX/RWX) when pods land
220+
# on multiple nodes.
221+
shared_volume = { claim_name = "models", mount_path = "/models" }
197222
```
198223

224+
Each pool maps to one `(image, runtimeClass, gpu)` shape. The writable per-agent
225+
workspace (`/sandbox`) on a pooled pod is an ephemeral `emptyDir` seeded from the
226+
image — it is never shared and is reclaimed with the pod, so claimed pods are
227+
single-use. Large shared files belong on the read-only `shared_volume` instead.
228+
The Helm chart exposes this as `server.warmPool.{enabled,pools}`.
229+
230+
A pooled pod enforces the pool's baseline policy and cannot be assigned a
231+
per-sandbox policy after it boots, so a `sandbox create` request that supplies a
232+
custom policy automatically falls back to the cold create path (its policy is
233+
applied faithfully). Requests for a non-default image, a custom template, or
234+
extra environment variables also fall back to cold.
235+
199236
### Docker
200237

201238
Sandboxes run as containers on a local bridge network. The supervisor binary is bind-mounted from the host (no in-cluster image pull required); guest mTLS material is supplied as host paths.

0 commit comments

Comments
 (0)