OpenClaw on Knative

A local Kubernetes experiment that scales an agent runtime to zero between requests.

By Himan MandujaSource reviewed Reviewed commit f91532c ↗

On this page
  1. Preparing the local cluster
  2. A request wakes the gateway
  3. State across scale-to-zero
  4. Configuration versus persistence
  5. Operational boundaries
  6. Source files

Scale-to-zero is straightforward for a stateless endpoint. An interactive gateway adds a more interesting question: what happens to its workspace and configuration when the pod disappears? This project explores that question by running OpenClaw as a Knative Service on a local Kubernetes cluster.

The build combines Knative Serving, Kourier ingress, Kubernetes configuration and secrets, and a persistent volume. It is a local development experiment with recorded startup and scale-down behavior, rather than a public agent-hosting platform.

Preparing the local cluster

The Linux/macOS and PowerShell scripts target Minikube or kind. They install Knative Serving and Kourier at knative-v1.22.0, wait for the control-plane deployments, select Kourier as ingress, and enable the Knative feature flags needed for persistent volumes.

They then configure a local domain, create the agents namespace, store the Gemini API key and gateway password in a Kubernetes Secret, and apply the service manifest. A Kourier port-forward supplies local access. The scripts wait for Knative readiness, but the background port-forward itself receives only a short sleep rather than an explicit connection check.

Knative activation with persistent gateway stateA local Kourier port-forward provides ingress. The PVC survives pod termination; existing configuration is only seeded when absent. Components: Browser, localhost route; Kourier, Local port-forward; Knative Serving, Activation + autoscaling; OpenClaw pod, 0–1 replica; ConfigMap / Secret, Seed config + credentials; 10 GiB PVC, Workspace + config.LOCAL MINIKUBE / KIND CLUSTERpersistseed on first bootBrowserlocalhost routeKourierLocal port-forwardKnative ServingActivation + autoscalingOpenClaw pod0–1 replicaConfigMap / SecretSeed config + credentials10 GiB PVCWorkspace + config
Architecture reconstructed from the linked implementation.Swipe to inspect →
A local Kourier port-forward provides ingress. The PVC survives pod termination; existing configuration is only seeded when absent.

A request wakes the gateway

Traffic to openclaw.agents.localhost enters through the local Kourier forward and Knative routing. The service manifest sets minimum scale to zero, maximum scale to one, and container concurrency to one. It also sets a five-minute scale-to-zero retention period.

These values make the workload deliberately single-instance. This is an experiment in idle-resource reduction and activation, not horizontal throughput scaling. The README gives a cold-start estimate, but the repository does not provide a benchmark method or measured CI report, so there is no measured latency claim in this case study.

kubectl watch output showing an OpenClaw pod entering Terminating and Completed states
The recorded watch shows a pod leaving Running and entering termination. This captures lifecycle state rather than measured idle-resource savings. Repository source ↗
kubectl watch output showing a replacement OpenClaw pod Pending and ContainerCreating
A later capture shows a replacement pod moving through Pending and ContainerCreating. Repository source ↗

State across scale-to-zero

A 10 GiB ReadWriteOnce claim is mounted at /home/node/.openclaw. The pod can terminate while its workspace survives. That storage choice is part of the reason to examine the one-replica limit: shared persistent state and concurrent replicas would require a different design.

Persisting state also changes recovery behavior. Starting a fresh container does not necessarily mean starting from a clean workspace. Troubleshooting must distinguish an image problem, a configuration problem, and data already present on the volume.

kubectl watch output with an OpenClaw pod Running beside the gateway login screen
The replacement pod reaches Running. The browser still shows a gateway-token error, so pod readiness does not prove an authenticated application session. Repository source ↗

Configuration versus persistence

The README says startup refreshes openclaw.json from the ConfigMap on every boot. The checked manifest behaves differently: it copies the seed configuration only when the file does not already exist on the PVC.

That means runtime edits can survive restarts, and a changed ConfigMap may not replace an existing file. This is an important implementation detail, because an operator could otherwise expect a restart to undo a bad configuration. The article follows the conditional copy in the manifest rather than repeating the stronger README claim.

Operational boundaries

The container configuration drops capabilities, disables service-account token mounting, and uses a runtime-default seccomp profile. At the same time, device-pairing protection is explicitly disabled for local development, and the application image uses the floating latest tag.

The scripts also modify cluster-wide Knative configuration, including the domain map. A disposable local cluster is the appropriate context for that behavior. Before adapting it for shared infrastructure, the next steps would include scoped configuration, restored device protection, an immutable image reference, and a documented policy for refreshing persisted configuration. Those improvements remain future work.

Source files