Skip to content

openshell-driver-openshift: supervisor init and sandbox token issues with mvp-v2 images #1815

Closed
rossoctl/openshell-driver-openshift
#7

Description

@pdettori

Summary

The compute driver (openshell-driver-openshift) creates sandbox init containers with command: ["sh", "-c", "cp /openshell-sandbox /opt/openshell/bin/"]. This worked with the old mvp supervisor image (Ubuntu-based), but fails with the mvp-v2 supervisor image which is a scratch/distroless image containing only the static binary — no sh, no cp.

Reproduction

  1. Deploy OpenShell with mvp-v2 images:

    • Gateway: ghcr.io/kagenti/openshell/gateway:mvp-v2-3a1bbea
    • Supervisor: ghcr.io/kagenti/openshell/supervisor:mvp-v2-9a6a0ed
    • Compute driver: ghcr.io/kagenti/openshell-driver-openshift/compute-driver:mvp-a5f33f4
  2. Create a sandbox: openshell sandbox create --provider claude --no-auto-providers -- claude

  3. Init container supervisor-init fails:

exitCode: 128
message: "exec: \"sh\": executable file not found in $PATH"
reason: StartError

Root Cause

The mvp-v2 supervisor Dockerfile switched from a full Ubuntu base to a scratch image. The image only contains /openshell-sandbox — no shell, no coreutils.

The compute driver hardcodes the init container command as:

command: ["sh", "-c", "cp /openshell-sandbox /opt/openshell/bin/ && cp /openshell-sandbox /opt/openshell/bin/"]

Proposed Fix

Replace the shell-based copy with a direct binary invocation. Two options:

Option A: Add a copy subcommand to the supervisor binary

The supervisor binary itself could support a copy mode:

// Init container spec
Command: []string{"/openshell-sandbox", "copy", "--to", "/opt/openshell/bin/"}

This requires a change in the upstream OpenShell supervisor code (kagenti/OpenShell@mvp-v2).

Option B: Use the binary as its own copier via a static entrypoint

Since the binary is statically linked, use a multi-stage approach where the init container just needs the binary to exist at the destination. The simplest fix is to change the init container to use the image's entrypoint or a direct file path without a shell:

// Use cat-style copy: read binary, write to volume
Command: []string{"/openshell-sandbox"}
Args:    []string{"--copy-self", "/opt/openshell/bin/openshell-sandbox"}

Option C: Use install from the image (quick fix, needs busybox layer)

Add a busybox layer to the supervisor Dockerfile for the copy operation. Least invasive to driver code but adds image size.

Context

  • Tracked by: Update OpenShell deployment to use mvp-v2 branch #1813 (Update OpenShell deployment to use mvp-v2 branch)
  • Repo: kagenti/openshell-driver-openshift (issues disabled there)
  • The gateway image works correctly with mvp-v2
  • The compute driver and credentials driver sidecars are unaffected
  • Only the supervisor init container mechanism is broken

Activity

  1. added a commit that references this issue on Jun 4, 2026
    6115313
  2. changed the title [-]openshell-driver-openshift: supervisor init container fails with mvp-v2 scratch image[/-] [+]openshell-driver-openshift: supervisor init and sandbox token issues with mvp-v2 images[/+] on Jun 4, 2026
  3. pdettori commented on Jun 4, 2026

    @pdettori
    MemberAuthor

    Update: second issue found — missing sandbox token

    The v0.1.0-rc.1 driver fixes the init container (scratch image copy works), but the sandbox supervisor still can't connect back to the gateway:

    no sandbox token source available — set one of OPENSHELL_SANDBOX_TOKEN, OPENSHELL_SANDBOX_TOKEN_FILE, or OPENSHELL_K8S_SA_TOKEN_FILE
    

    Root Cause

    The mvp-v2 supervisor requires an authentication token to establish the relay session back to the gateway. The Kubernetes service account token is already mounted at the default path (/var/run/secrets/kubernetes.io/serviceaccount/token), but the compute driver doesn't set the env var to tell the supervisor where to find it.

    Fix

    The compute driver should inject this env var into sandbox pods:

    {Name: "OPENSHELL_K8S_SA_TOKEN_FILE", Value: "/var/run/secrets/kubernetes.io/serviceaccount/token"}

    Current status with v0.1.0-rc.1

    Step Status
    Init container (binary copy from scratch image) ✅ Fixed
    Supervisor mTLS to gateway ✅ Working (certs mounted)
    Supervisor auth token ❌ Missing OPENSHELL_K8S_SA_TOKEN_FILE env var
    Sandbox session relay ❌ Blocked by above
  4. pdettori commented on Jun 4, 2026

    @pdettori
    MemberAuthor

    Update: projected SA token with audience openshell-gateway required

    With PR #1819 deployed (gateway JWT auth enabled), we confirmed the K8s SA authenticator activates correctly. However the sandbox bootstrap still fails because the compute driver v0.1.0-rc.2 uses the default K8s SA token mount:

    OPENSHELL_K8S_SA_TOKEN_FILE=/var/run/secrets/kubernetes.io/serviceaccount/token
    

    This token carries audience https://kubernetes.default.svc.cluster.local. The gateway's TokenReview rejects it:

    K8s TokenReview did not authenticate token
      error="token audiences [\"https://kubernetes.default.svc.cluster.local\"] is invalid for the target audiences [\"openshell-gateway\"]"
    

    Required fix in compute driver (v0.1.0-rc.3)

    The driver must create a projected volume with the correct audience:

    volumes:
    - name: openshell-sa-token
      projected:
        sources:
        - serviceAccountToken:
            audience: "openshell-gateway"    # must match gateway expectation
            expirationSeconds: 3600
            path: "token"
        defaultMode: 0400

    Mount at /var/run/secrets/openshell/token and set:

    OPENSHELL_K8S_SA_TOKEN_FILE=/var/run/secrets/openshell/token
    

    Reference: kagenti/OpenShell@mvp-v2:crates/openshell-driver-kubernetes/src/driver.rs — the upstream in-tree driver uses this exact projected volume configuration.

    Status

    Component Status
    Gateway JWT issuer (PR #1819) ✅ Working — K8s SA authenticator enabled
    Gateway TokenReview RBAC ✅ Working — ClusterRole grants tokenreviews: create
    Compute driver sandbox pod creation ✅ Working
    Compute driver projected token volume ❌ Missing — uses default SA token, wrong audience
  5. pdettori commented on Jun 4, 2026

    @pdettori
    MemberAuthor

    Fix: projected SA token volume — PRs ready

    The compute driver fix is implemented and tested:

    openshell-driver-openshift (PR #7)

    Adds a projected serviceAccountToken volume with:

    • audience: openshell-gateway (matches gateway TokenReview expectation)
    • expirationSeconds: 3600 (configurable via -sa-token-ttl-secs flag)
    • mountPath: /var/run/secrets/openshell/token
    • env: OPENSHELL_K8S_SA_TOKEN_FILE=/var/run/secrets/openshell/token

    New CLI flags:

    -sa-token-audience  (default: "openshell-gateway")
    -sa-token-ttl-secs  (default: 3600)
    

    kagenti/kagenti (PR #1814, latest commit)

    • Passes -sa-token-audience and -sa-token-ttl-secs to compute driver in Helm chart
    • Bumps compute driver image to v0.1.0-rc.3

    Next steps

    1. Merge driver PR → tag v0.1.0-rc.3 → image builds
    2. Kind full test with PR feat(openshell): update deployment to use mvp-v2 branch #1814 to validate end-to-end sandbox auth flow
  6. pdettori commented on Jun 4, 2026

    @pdettori
    MemberAuthor

    Update: TokenReview passes, pod annotation mismatch remains

    With v0.1.0-rc.3, the projected token with audience openshell-gateway works correctly:

    validated K8s SA token via TokenReview pod_name=celestial-killdeer service_account=openshell-sandbox ✅
    

    However, IssueSandboxToken still fails after pod lookup because the gateway expects annotation openshell.io/sandbox-id on the pod, but the driver sets label openshell.ai/sandbox-id instead.

    What gateway expects What driver sets
    Annotation openshell.io/sandbox-id Label openshell.ai/sandbox-id
    Domain: openshell.io Domain: openshell.ai

    Reference: kagenti/OpenShell@mvp-v2:crates/openshell-server/src/auth/k8s_sa.rs checks pod.metadata.annotations["openshell.io/sandbox-id"].

    Fix needed in compute driver (v0.1.0-rc.4)

    The driver must set:

    metadata:
      annotations:
        openshell.io/sandbox-id: "<uuid>"    # annotation, not label; .io not .ai

    The existing label can stay for backwards compat, but the annotation is what the gateway requires.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions