Kubernetes Compute Driver
Contents
Overview
This implementation follows the ComputeDriver contract.
Kubernetes Compute provisions or adopts one namespace per tenant and creates each
Agent’s gateway. Dedicated Gateways and Harnesses use separate Pods, identities
and volumes; embedded OpenClaw shares one Pod. Experimental executionCluster
places dedicated Harnesses in a second cluster;
cloud and complete runtime acceptance remain pending.
New managed namespaces use oce- plus 15 hexadecimal characters of the Namespace
ID’s SHA-256 digest, which fits OpenShell pre.5 Workspace names. Earlier
oce-<slug>-<hash12> namespaces require the exact tenant label, matching
namespace-id annotation and OpenClaw manager label; the Driver never creates
this form. Wrong names or duplicate tenant claims fail closed. Adopted namespaces
keep their names; OpenShell rejects names exceeding its Workspace limit.
The optional OpenShell Sandbox Driver is designed to own dedicated Codex and native OpenClaw Harness Pods while Compute keeps the other resources. Dedicated native OpenClaw requires a selected SandboxDriver that provisions the Harness and declares networking, filesystem, and process containment. Stock OpenShell cannot provide required credential and workload-identity projections; Agent deployment with OpenShell remains unsupported.
Operator contracts:
- Storage and credentials: separate gateway state, Harness workspaces, and runtime Secrets.
- Networking and isolation: DNS, private gateway routes, and tenant namespace ownership.
Lifecycle
Execution modes
Each Agent-owned gateway Deployment has exactly one desired replica and uses
Recreate: Kubernetes stops the previous Pod before starting its replacement,
so gateway rollout can cause transient downtime. Neither Kubernetes Deployment nor OCC routing provides node-level process
fencing during partitions or manual replacement.
Harness configuration selects the Agent's execution topology:
- Embedded: OpenClaw runs the gateway and Harness in one Pod. It accepts
an Agent-scoped model API key, uses
openai/models, and does not require shared storage. For custom OpenAI-compatible HTTPS endpoints, see model provider configuration. - Dedicated: The gateway and Codex Harness run in separate Pods in the same
tenant namespace, with separate ServiceAccounts and storage. They communicate through
authenticated app-server transport. The Gateway uses fully qualified Harness
Service DNS and the paired node for workspace operations. Codex accepts an
Agent-scoped model API key or a managed ChatGPT service-account credential,
and permits
openai/orcodex/models. - Dedicated native OpenClaw: The gateway and paired OpenClaw Harness run in
separate Pods with separate ServiceAccounts. Compute issues a node-only setup
credential through the gateway and stores the resulting device identity on the
Harness workspace claim. The node host supervises the remote worker, which owns
the agent loop, model inference, and coding tools. Only the Harness receives the
model API key. Compute makes its generated
dedicated-nativeworker-inference profile mandatory, so sessions use the enrolled Harness without a Cloud Worker selection. A missing or disconnected Harness fails the turn without gateway inference fallback. Explicitopenai/models require complete API, token-limit, input, reasoning, and cost metadata. Custom endpoints require the shared provider, endpoint-boundcredential_sourceauthentication and HTTPS on port 443 ending in/v1. Secret-backed keys requirehttps://api.openai.com/v1. Model URLs reject credentials, queries, fragments and wildcards.
Dedicated replacement opts into the exclusive preparation contract: the worker stops predecessors before starting the new Harness. This permits RWO workspace storage with deployment downtime; restore previous configuration through a new version instead of restarting its old snapshot.
Enabled external channels require dedicated execution. Unsupported Harness and execution-mode combinations fail deployment. Embedded OpenClaw is never delegated to OpenShell.
Stopping an Agent first deletes its exact gateway route and gateway runtime, then removes the dedicated Harness Deployment or delegates provider-owned Harness removal; Sandbox cleanup follows the provisioning lifecycle. Stop retains Agent-owned PersistentVolumeClaims and runtime credential Secrets; retirement removes resources for that Agent revision. Repeated stop observes exact ownership and converges when the runtime objects are already absent.
Plugin startup status
Compute-owned OpenClaw and Codex runtimes publish private startup results after
attempting plugins and verifying configuration: Agent revision ID, runtime instance,
successful selection IDs, and warnings
(PLUGIN_INSTALL_FAILED or PLUGIN_AUTH_REQUIRED) for disabled selections.
Compute reads the exact workload through the authenticated Pod proxy under
tenant-local RBAC; workloads receive no Kubernetes write credentials. The endpoint
is not public. Ownership, startup identity, selection keys, and warning codes
must match; missing, malformed, or foreign status cannot establish readiness.
Embedded OpenClaw disables failed plugins and their managed tool allowances before Gateway startup. Dedicated Codex applies current results before serving and refreshes them after changed restart results. Failed-only app bindings are disabled; successful selections retain admitted policy and required shared bindings.
The Codex app-server credential derives from the Agent's transport Secret, Agent revision ID, and startup identity, so a gateway configured for the previous startup cannot authenticate to a restarted Agent. Its supervisor obtains the new status, applies the matching exclusions, and respawns the gateway process with the new credential, closing the interval before its next status poll.
The worker commits warnings with successful deployment under its live claim; restarts recompute status. No receipt ConfigMaps, finalizers, failure latches, or post-commit acknowledgments are used. Requested selections and account-wide installations remain unchanged; rollback is not promised.
Current runtime diagnostics
Kubernetes Compute implements the optional deployment diagnostics contract. OCC
authorizes the specific Agent and Agent revision, then the Driver reads the owned
runtime Pods through the Kubernetes apiserver Pod proxy. The private runtime
endpoint returns generic checks for the requested Agent revision ID. Compute
rejects responses larger than 65,536 bytes or containing more than 32 checks. The API needs
Pod get/list and pods/proxy get permission in each runtime namespace.
Both roles are read in the tenant namespace for a single cluster. The two-cluster
profile reads dedicated Gateways in its control-cluster Gateway namespace. The chart adds these read permissions to the
unbound tenant API and Gateway observer roles; operators retain control of their
namespace-local bindings.
Missing Pods or unavailable private endpoints report unknown diagnostic checks
instead of mutating deployment status. The Agent container currently returns no
channel checks.
The bundled gateway maps Slack channel status into configuration, authentication, and connectivity checks. They exclude raw Slack responses, credential values, logs, and message text, and never post a message or run a model turn.
Sandbox provisioning
With OpenShell sandboxing, composition adapts SandboxDriver.ensureNamespace
to OCC Namespace lifecycle hooks. Compute resolves the exact backing namespace
and selected Kubernetes client without calling Sandbox. The hook applies approved
namespace-scoped OpenShell labels and NetworkPolicy resources, checks OpenShell
gateway readiness, and creates or adopts the Namespace Workspace. Harness
provisioning and cleanup follow the SandboxDriver lifecycle:
Agent revision cleanup runs even when Compute's ordinary Harness Deployment is absent,
and a failed provider Namespace cleanup keeps the Kubernetes namespace.
Provider-owned Harness removal stays with the provider, so Compute needs no
Sandbox custom-resource permissions.
Allow privileged OpenShell init or sidecar containers only through an
operator-approved RuntimeClass or equivalent admission exemption with a matching
fail-closed policy (admission requirements);
the Harness container itself remains unprivileged.
A provider-owned dedicated Harness is ready only when exactly one live Pod in
the resolved namespace carries the Agent ID, Agent revision ID, and agent workload-role
labels used by the active Service selector, plus all supplied Harness
requirement labels, and reports Ready=True. Zero candidates, multiple live
candidates (including one Ready and one unready), or a single unready candidate
leave preparation at ready: false and prevent activation. Pods with a valid
deletion timestamp, in another namespace, or with another Agent ID, Agent revision ID, or
role do not count.
Malformed or incomplete Pod lists, invalid identities or conditions, duplicate condition types, contradictory Harness labels, and pagination with more results are errors. Missing optional status or conditions means not ready. Preparation errors run workload cleanup hooks; activation errors precede routing changes. Cancelled observations cannot report ready. Checks establish workload readiness and label uniqueness, not Sandbox IDs, Pod UIDs, guest authentication or runtime generation fencing.
Selected-driver lifecycle hooks
The Driver invokes selected non-Compute lifecycle hooks around Namespace preparation and workload startup or teardown. Hooks receive the operation's cancellation signal; failed revocation blocks resource teardown. The ComputeDriver contract owns the hook ordering and environment restrictions, and the lifecycle-hook flow traces the implementation.
Configuration
Set drivers.compute.id: compute-kubernetes in the Installation YAML loaded
by both API and worker through OCC_CONFIG_PATH. Restart both after changes.
The field tables and example define the
settings inside drivers.compute.configuration:
| Setting | Type | Requirement | Value, default, and constraints |
|---|---|---|---|
authentication |
object | Required | Explicit in-cluster identity or named kubeconfig context. |
images |
object | Required | Gateway/Agent images and immutable-digest policy. |
resources |
object | Required | Workload requests/limits and namespace quotas/defaults. |
network |
object | Required | DNS, gateway port, proxy trust, and permitted peers. |
servicePrincipalCredentials |
object | Required | Explicit workload-identity projection policy. |
runtime |
object | Optional | Required in production; omission selects the verification runtime. |
gatewayRouting |
object | Conditional | Dedicated Harnesses with runtime need this and node enrollment. |
executionCluster |
object | Optional | Experimental second cluster; omitted by default. |
See authentication and images and resources.
Limits
Requirements
- Kubernetes 1.35 or later. On older, unsupported versions the API and worker
log
compute.preflight-warningand start. - A Kubernetes cluster dedicated to one OpenClaw Enterprise Installation; shared clusters are not supported.
- Enforced Kubernetes NetworkPolicies, verified Kubernetes API TLS, and restricted Pod security.
- Separate controller API and worker ServiceAccounts with operator-managed, tenant-local permissions.
- API and worker permission to
GETthe Kubernetes/versionnon-resource URL, granted by the production chart's narrowly scoped startup Namespace ClusterRoles. - Approved, digest-pinned gateway and Agent images.
- Explicit container resource limits, namespace quotas, DNS settings, approved
proxy clients, and
network.gatewayTrustedProxyCidrsfor gateway trust. Native workspace initialization usesresources.gateway, including in dedicated Harness Pods, because it loads the OpenClaw CLI. - For real gateways in either topology, an explicitly selected
runtime.gatewayStorageClassNamefor a private disk supporting the configured Gateway capacityReadWriteOncefilesystem claims (local-pathin the disposable k3d suite). Check the gateway disk requirements before selecting a production StorageClass. - For dedicated Agents, a default StorageClass that supports
40GiReadWriteOncePersistentVolumeClaims. - If
runtime.codexSeccompProfileis configured, install that relative localhost seccomp profile on every eligible node before Agent startup; Kubernetes fails the Codex Pod when it is missing.
The worker manages PersistentVolumeClaims and, when private gateway routing is enabled, HTTPRoutes through tenant-local RoleBindings. Only the controller API issues provider credentials. The worker reads admitted transport/channel material and maintains Harness Secret projections for each Agent revision in the tenant namespace. The API does not need gateway Pod reads, exec, route writes, or certificate management for workspace-file access. Do not grant wildcard permissions, cluster-wide access to tenant resources, workload access to controller credentials, or permission to create or escalate RoleBindings.
Existing split-layout installations
Releases before #925 kept each Namespace's Gateways, Gateway state and canonical
Secrets in a separate oce-gateways-<hash> namespace. Check for and adopt these
tenants with Existing split-layout installations
before replacing the controller images.
Troubleshooting
- Namespace provisioning fails: A
worker.completedlog fornamespace.ensurewithhintCode: KUBERNETES_TENANT_ACCESS_DENIEDmeans Kubernetes returned HTTP 403 while the worker reconciled the tenant's quota, limits, or network policies. Check the worker's tenant-local RoleBinding in the affected target. Also verify namespace ownership labels, restricted Pod Security labels, and enforced NetworkPolicies in each selected tenant target. Existing namespaces also require external lifecycle ownership, exclusive tenant use, and no foreign NetworkPolicies. - Gateway or Harness remains pending: Check image digests, image pull
permissions, CPU and memory limits, namespace quotas, required Secrets, and
workload readiness, including the
network profile
label. Private HTTP readiness returns
503until native, plugin, authentication, or identity gates pass. Dedicated Codex clears its plugin marker at process start to reject stale readiness. For Compute-owned Harnesses, resident HTTPGET /readyzrequires a successful loopback app-serverinitializeresponse. It creates no thread or model turn. The resident RPC check has a two-second internal deadline; Kubernetes retains its one-second default HTTP-probe timeout. This does not verify the Gateway's network path to the Harness. Access-token login retries timeouts,networkandhttp_5xxfailures: five attempts, 90 seconds. Exhausted startup remains unready until an explicit restart; see the authentication probe contract for model-probe retries and sanitized attempt logs. Native plugin startup, authentication, transport, and installation failures remain generic workload startup failures unless the Compute-owned runtime reports a verified current-startup warning for an admitted selected plugin. - Check
gateway-configfails: See configuration OpenClaw refuses. RUNTIME_STARTUP_FAILEDwith a container inCrashLoopBackOff: A live Pod'sgatewaycontainer, or a Deployment-runagentcontainer, exited 3 times in a row without a deliberate restart (internal checkcrash-loop). The Gateway wrapper exits 75 and logs startup phasecontainer-restartwhen it restarts its container on purpose; those restarts never count, and readiness resets the count. Without the wrapper's count (a Harness, or an older Pod), restart count 2 in backoff is the third exit.occ agent runtimeshows the restart count and last exit code;occ agent logs --previousshows the crashed container's output.- Gateway storage is pending or rejected: Check the configured
runtime.gatewayStorageClassName, available space for the configured Gateway capacity, filesystem support, worker PVC permissions, and the PVC's exact ownership. Preserve data when resolving an incompatible or foreign claim; the driver does not adopt or convert it. - Dedicated Harness cannot start: Verify the default StorageClass supports
a
40GiReadWriteOnceclaim and the worker can manage PersistentVolumeClaims in the tenant namespace. - Agent configuration is rejected: Confirm the selected Harness supports its execution mode; external channels and provider-issued access tokens require dedicated execution.
- An Agent with repository bindings is refused for its Codex proxy: Agent
save, provisioning and deployment answer
400whenplugins.entries.codex.config.appServer.networkProxyhasenabled: false, amodeother thanlimitedorfull, a non-booleanallowLocalBinding, ordomainsthat is not an object mapping each host toallowordeny. Preparation also refuses a deny of the broker hostname, which only session material names. Fix or delete the named setting, or remove the bindings; see repository broker policy. - Approved traffic fails or denied traffic succeeds: Verify NetworkPolicy enforcement, configured DNS selectors, gateway-client selectors, and any configured channel proxy address.
- Production startup fails: Confirm the controller API and worker share the
same
OCC_CONFIG_PATH, image digests are immutable, Kubernetes credentials are valid, and required runtime Secret prefixes are configured.
