Run attempt environments on Kubernetes¶
The Kubernetes environment adapter creates a pod and a ClusterIP service for each attempt. The pod runs the Codex exec server, and its configured RuntimeClass supplies workload isolation. The runtime adapter keeps its model credentials in its own process. The workload pod starts with service account token mounting disabled and receives only the hash of its per-attempt attach token.
Use a dedicated environment namespace with a CNI that enforces NetworkPolicy. Restrict writes in this namespace to the adapter and administrators. NetworkPolicy allow rules are additive. Keep other policies from granting access to the workload pods, and validate the selected runtime and CNI block direct access to the node and cluster control plane. The workload policy allows TCP egress to one configured proxy IP and port and ingress from labelled runtime pods on the exec server port. The supplied proxy must have its own destination policy. Use a stable reachable IP whose identity is preserved by your CNI's policy enforcement.
Deploy the adapter¶
- Create the control namespace named
dac-plane. If your deployment uses another name, edit the service account and its subject indeploy/kubernetes/environment-rbac.yaml. - Apply that manifest and verify the CNI has enforced its namespace-wide default deny before
starting the adapter. Deploy the
dac-kubernetes-adapterimage built from the root Dockerfile target of the same name. Run one replica for the provider, with the manifest's service account and a writable persistent volume forDAC_KUBE_STATE. Use a Recreate rollout for that replica. - Register the adapter as an environment provider and supply its OIDC configuration using the common adapter settings.
- Set the Kubernetes adapter settings.
The workspace image must contain a pinned compatible Codex CLI and the tools its workspace
sandbox needs. The configured RuntimeClass must support that sandbox. Create a TLS secret
in the environment namespace with a certificate for
*.dac-plane-environments.svc. Mount its issuer CA in the runtime's trust store. The adapter image also runs the TLS sidecar. Use its digest inDAC_KUBE_EXEC_PROXY_IMAGE. - Label the Codex adapter pod template
dac-plane.dev/exec-client: "true"in the runtime namespace. Mount the same attach key on both adapters. SetDAC_CODEX_EXEC_SERVER_URLtowss://{resource}.dac-plane-environments.svc:8080andDAC_CODEX_WORKSPACEto/workspace. - Reference the registered environment provider when provisioning an agent and submit a task.
The adapter writes a running observation after the pod passes its readiness probe. A stop requests normal, UID-preconditioned deletion and records absence after the pod is gone and the service is removed. The pod lifetime is capped at one hour or the remaining task deadline, whichever comes first. Workspaces are ephemeral. Persist outputs as task artifacts before the attempt ends.
Qualify the deployment¶
Run just test-kubernetes-qualification with Docker, kubectl, and OpenSSL installed. It creates
and removes a disposable kind cluster and checks the real Kubernetes API, a Codex exec-server
command over WSS, the workload credential mounts, proxy egress, and pod and service deletion.
It uses kind's runc handler. Repeat the checks below with the RuntimeClass, proxy, and CNI
that you deploy.
Run a task that writes a marker in its workspace and read it back through the runtime adapter. Check that the marker is inside the attempt pod and absent from the runtime pod. From inside the workload verify that the service account token path is absent, that the named proxy is reachable, and that direct connections to an external endpoint, the node, and the control plane fail. Cancel a running command and check the pod, service, and command are gone before accepting the absence observation as deployment evidence.