Introduction

For teams needing high availability, auto-scaling, or multi-gateway deployments, Kubernetes provides a robust orchestration platform. OpenClaw can be deployed to any Kubernetes cluster, with GCP's GKE and Hetzner Cloud being popular choices.

Key Concepts

  • Deployment: A Kubernetes resource that manages the gateway pod lifecycle, including replicas and rolling updates.
  • PersistentVolumeClaim (PVC): Provides durable storage that survives pod restarts, used for agent data.
  • Service: Exposes the gateway pod within the cluster or to the internet.
  • ConfigMap / Secret: Stores gateway configuration and credentials separately from the pod definition.

Real World Context

An enterprise runs three OpenClaw gateways on GKE: one for the engineering team, one for the support team, and one for the executive assistant. Each gateway has its own Deployment, PVC, and Service. Kubernetes handles automatic restarts, health monitoring, and resource allocation.

Deep Dive

A complete Kubernetes deployment includes a PVC, Deployment, and Service:

yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: openclaw-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: openclaw-gateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: openclaw-gateway
  template:
    metadata:
      labels:
        app: openclaw-gateway
    spec:
      containers:
        - name: gateway
          image: openclaw/gateway:2026.2.19
          ports:
            - containerPort: 18789
          volumeMounts:
            - name: data
              mountPath: /root/.openclaw
          envFrom:
            - secretRef:
                name: openclaw-secrets
          livenessProbe:
            exec:
              command: ["openclaw", "status"]
            initialDelaySeconds: 30
            periodSeconds: 60
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: openclaw-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: openclaw-service
spec:
  type: ClusterIP
  ports:
    - port: 18789
  selector:
    app: openclaw-gateway

This manifest creates a 10GB persistent volume, a Deployment with health probes, and a ClusterIP Service. Secrets are loaded from a Kubernetes Secret resource. The liveness probe runs openclaw status every 60 seconds.

Note that replicas is set to 1. OpenClaw gateways are stateful (session data, channel connections), so running multiple replicas of the same gateway requires careful session affinity.

Common Pitfalls

  1. Running multiple replicas without session affinity — Each gateway instance maintains its own channel connections and sessions. Multiple replicas without sticky sessions cause message duplication and connection conflicts.
  2. Using emptyDir instead of PVC — emptyDir volumes are lost when the pod is rescheduled to a different node.

Best Practices

  1. Use a single replica per gateway — Run one pod per gateway and use multiple gateways (Deployments) for scaling across teams.
  2. Back up PVCs regularly — Use Velero or volume snapshots to back up agent data.

Summary

  • Kubernetes provides robust orchestration for OpenClaw with health probes and automatic restarts
  • PersistentVolumeClaims ensure agent data survives pod restarts and rescheduling
  • Run one replica per gateway due to stateful channel connections
  • Use Kubernetes Secrets for credential management
  • Multiple gateways are deployed as separate Deployments, not multiple replicas
✓ Completed