Skip to content

feat(driver-kubernetes): support per-sandbox image-pull Secret references - #6190

Open
vassilnk wants to merge 3 commits into
ai-openshell:mainfrom
vassilnk:feat/5113-per-sandbox-image-pull-secrets/vassilnk
Open

vassilnk wants to merge 3 commits into
ai-openshell:mainfrom
vassilnk:feat/5113-per-sandbox-image-pull-secrets/vassilnk

Conversation

@vassilnk

@vassilnk vassilnk commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary

Add per-sandbox, caller-selected image-pull Secret references for the Kubernetes compute driver. A caller passes template.driver_config.kubernetes.pod.image_pull_secrets (up to 8 existing Secret names); the gateway admits each by the same workspace-label mechanism as caller PVCs and appends them to the workload Pod's imagePullSecrets. OpenShell references existing Secrets only — it never uploads, creates, or copies them. The feature is strictly opt-in and rejected in managed mode.

Related Issue

Closes #5113

Changes

  • driver-kubernetes: parse/validate (Kubernetes resource-name rule, max 8, no duplicates), gate, admit as workspace-scoped resources, render into the Pod without duplicates, record the caller selection in a driver-owned annotation, and re-gate on restart and revalidation. The opt-in (allow_driver_config_image_pull_secrets; standalone --allow-driver-config-image-pull-secrets) lives on the Kubernetes driver's own config, not the shared DriverAdmissionConfig, since it is Kubernetes-only. The driver fails closed at startup (and in config preflight) unless allow_driver_config is set, resource_admission is enabled, and a required label pins the caller workspace via ${workspace}. Caller vs gateway-owned Secrets are distinguished by the annotation, not the rendered names, so this composes with managed mode's per-generation Secret copies. Gateway-wide names are normalized once at init so trimmed rendered names match the admission exemption set.
  • helm: gate the namespaced get secrets RBAC on both flags in the openshell and openshell-workspace Role templates; write the snake_case driver key only when the opt-in is on; the gateway ClusterRole never grants get secrets.
  • docs: document the interface, additive behavior, approval/namespace requirements, platform provisioning responsibility, and that the RBAC get returns full Secret data (recommend a sandbox namespace separate from the gateway's own Secrets).

Reviewer notes:

  • The flag is intentionally driver-local, not on the shared DriverAdmissionConfig, so it does not touch the desktop driver crates frozen by ci: freeze desktop driver paths while they move to ai-openshell/desktop #6124. The trade-off: the gateway↔driver acknowledgement no longer cross-checks this specific flag, which is acceptable for a Kubernetes-only, in-gateway driver.
  • is_kubernetes_resource_name also relaxes PVC claim_name validation (no per-segment 63-char cap) and adjusts its error text — correct per Kubernetes resource-name rules, but incidental to this feature.
  • Pre-existing and out of scope: metadata_lookup_error returns a distinct "does not exist" message for a 404 vs a label-mismatch rejection (a low-severity name-existence oracle in shared namespaces, CWE-204). It predates this feature and serves PVC admission too; better addressed in a separate issue than by changing a shared diagnostic here.
  • Three scope-separated commits with no file spanning two commits: feat(driver-kubernetes), feat(helm), docs.

Release Notes

The Kubernetes compute driver can now let sandbox callers select existing image-pull Secrets per request via driver_config.kubernetes.pod.image_pull_secrets, gated behind allowDriverConfig and a new allowDriverConfigImagePullSecrets opt-in. Selections reference existing Secrets approved by workspace labels and are rejected in managed mode.

Testing

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

Detail:

  • cargo fmt / cargo clippy (driver-kubernetes lib+tests) — clean
  • cargo test -p openshell-driver-kubernetes --lib — 378 passed (image-pull suite incl. gate, preflight-gate regression, and name normalization)
  • helm lint + helm unittest both charts — 528 + 9 passed
  • check_frozen_paths.py — no changes to frozen paths
  • e2e Kubernetes path (e2e/rust/e2e-kubernetes.sh on an ephemeral k3d cluster): 80/80 conformance passed (0 skipped) + 39/39 driver-suite passed (2 env-gated skips); cluster torn down cleanly. Run against the pre-rebase tip; the feature commits replayed cleanly onto current main with no content change.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

…nces

Expose pod.image_pull_secrets in the per-sandbox Kubernetes driver
config: a caller selects existing Secret names (max 8, validated as
Kubernetes resource names) that the gateway admits by the same
workspace-label mechanism as caller PVCs, then appends to the workload
Pod's imagePullSecrets without duplicates. OpenShell references existing
Secrets only; it never uploads, creates, or copies them.

Opt-in lives on the Kubernetes driver's own config as
allow_driver_config_image_pull_secrets (standalone --allow-driver-config-image-pull-secrets),
keeping it out of the shared DriverAdmissionConfig since it is
Kubernetes-only. The driver fails closed at startup unless
allow_driver_config is set, resource_admission is enabled, and a required
label pins the caller workspace via ${workspace}; managed mode rejects
any caller selection with FailedPrecondition before a lookup.

Admission distinguishes caller from gateway-owned Secrets via a
driver-owned annotation, not the rendered names, so it composes with
managed mode's per-generation Secret copies. Gateway-wide names are
normalized once at init so trimmed rendered names match the exemption
set. The caller selection is recorded and re-gated on restart and
revalidation, suspending a sandbox whose Secret drifts or whose operator
later disables the flag.

Issue: ai-openshell#5113
Signed-off-by: Vasil Kurdov <vasil.kurdov@sap.com>
Gate the namespaced get secrets RBAC rule on both allowDriverConfig and
allowDriverConfigImagePullSecrets in the openshell and openshell-workspace
Role templates, mapping legacy camelCase to snake_case. Only write the
snake_case driver key when the opt-in is on, so a newer chart rendering
gateway.toml for a pinned older gateway image does not emit an unknown
field. The gateway ClusterRole never grants get secrets: managed mode
does not support caller selection and rejects it with FailedPrecondition.

The RBAC rule grants get on all Secrets in the namespace (full data;
Kubernetes RBAC cannot restrict it to metadata), so the values, README,
and template comments describe the exposure and recommend a sandbox
namespace separate from the gateway's own TLS and database Secrets.

Issue: ai-openshell#5113
Signed-off-by: Vasil Kurdov <vasil.kurdov@sap.com>
Document the per-sandbox pod.image_pull_secrets interface: additive
behavior alongside gateway-wide references, the two required opt-in flags,
the approval and workspace-namespace requirements, and that the platform
is responsible for provisioning the referenced Secrets. Spell out that the
Secret get RBAC returns full Secret data (not metadata) and recommend a
sandbox namespace separate from the gateway's own Secrets.

Issue: ai-openshell#5113
Signed-off-by: Vasil Kurdov <vasil.kurdov@sap.com>
@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(driver-kubernetes): support per-sandbox image-pull Secret references

2 participants