πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Security intermediate ⏱ 20 minutes K8s 1.28+

OpenClaw Pod Security Hardening on Kubernetes

Harden OpenClaw pods with read-only filesystem, dropped capabilities, non-root user, seccomp profiles, and resource limits.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: OpenClaw’s official manifests already include read-only root filesystem, drop: ALL capabilities, non-root UID 1000, seccomp RuntimeDefault, and disabled service account token. This recipe explains each layer and how to verify compliance with Pod Security Standards.

The Problem

OpenClaw agents can execute shell commands, access files, and interact with external APIs. Running such a powerful tool without proper pod-level security creates risk: container escape, privilege escalation, or unauthorized cluster access. The official manifests include hardening by default β€” but you need to understand what each layer does and how to verify it.

The Solution

Security Layers in the Official Deployment

The OpenClaw deployment manifest includes these security controls:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: openclaw
spec:
  template:
    spec:
      # Disable service account token injection
      automountServiceAccountToken: false
      securityContext:
        # All volumes owned by UID/GID 1000
        fsGroup: 1000
        # Seccomp profile at pod level
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: gateway
          securityContext:
            # Must run as non-root
            runAsNonRoot: true
            runAsUser: 1000
            runAsGroup: 1000
            # No privilege escalation (no setuid)
            allowPrivilegeEscalation: false
            # Immutable container filesystem
            readOnlyRootFilesystem: true
            # Drop ALL Linux capabilities
            capabilities:
              drop:
                - ALL

What Each Control Does

ControlPurposeRisk Mitigated
runAsNonRoot: truePrevents running as UID 0Container escape via root
readOnlyRootFilesystem: trueContainer FS is immutableMalware persistence
drop: ALLRemoves all Linux capabilitiesPrivilege escalation
allowPrivilegeEscalation: falseBlocks setuid binariesPrivilege escalation
seccompProfile: RuntimeDefaultRestricts syscallsKernel exploits
automountServiceAccountToken: falseNo K8s API accessCluster compromise
fsGroup: 1000PVC files owned by app userPermission issues

Writable Volumes

Since the root filesystem is read-only, OpenClaw needs writable mounts:

volumeMounts:
  # Agent state, config, workspace
  - name: openclaw-home
    mountPath: /home/node/.openclaw
  # Temporary files (scratch space)
  - name: tmp-volume
    mountPath: /tmp
volumes:
  - name: openclaw-home
    persistentVolumeClaim:
      claimName: openclaw-home-pvc
  - name: tmp-volume
    emptyDir: {}
  • PVC (/home/node/.openclaw) β€” persists agent state, memory, workspace
  • emptyDir (/tmp) β€” ephemeral scratch, cleared on pod restart

Init Container Security

The init container that copies config files also runs hardened:

initContainers:
  - name: init-config
    image: busybox:1.37
    securityContext:
      runAsUser: 1000
      runAsGroup: 1000
    resources:
      requests:
        memory: 32Mi
        cpu: 50m
      limits:
        memory: 64Mi
        cpu: 100m

Verify Pod Security Standards Compliance

# Check against Restricted PSS level
kubectl label namespace openclaw \
  pod-security.kubernetes.io/enforce=restricted \
  pod-security.kubernetes.io/warn=restricted

# Deploy and verify β€” should create without warnings
kubectl apply -k scripts/k8s/manifests -n openclaw

# Audit existing pods
kubectl get pods -n openclaw -o json | \
  jq '.items[].spec.containers[].securityContext'
graph TD
    A[Pod Security Layers] --> B[Non-Root UID 1000]
    A --> C[Read-Only Root FS]
    A --> D[Drop ALL Capabilities]
    A --> E[Seccomp RuntimeDefault]
    A --> F[No SA Token]
    C -->|Writable| G[PVC: /home/node/.openclaw]
    C -->|Writable| H[emptyDir: /tmp]
    B --> I[fsGroup: 1000 owns PVC]

Additional Hardening: Pod Security Policy (PSA)

Label the namespace to enforce restricted Pod Security Standards:

apiVersion: v1
kind: Namespace
metadata:
  name: openclaw
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: latest
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/warn: restricted

Resource Limits

The deployment includes proper resource constraints:

resources:
  requests:
    memory: 512Mi
    cpu: 250m
  limits:
    memory: 2Gi
    cpu: "1"

These prevent a runaway agent from consuming cluster resources. Adjust based on workload:

  • Light usage (single user, simple tasks): 256Mi / 250m
  • Heavy usage (browser automation, multi-agent): 2Gi / 2 CPU
  • With Chromium sidecar: Add 1Gi / 500m for the browser container

Common Issues

CrashLoopBackOff with Read-Only FS

If OpenClaw tries to write outside the mounted volumes:

kubectl logs -n openclaw deploy/openclaw --previous
# Look for: "Read-only file system" errors

Fix: Ensure /home/node/.openclaw and /tmp are mounted as writable volumes.

Permission Denied on PVC

If fsGroup doesn’t match the running user:

kubectl exec -n openclaw deploy/openclaw -- ls -la /home/node/.openclaw
# Should show uid=1000 gid=1000

Seccomp Blocks Required Syscall

Rare, but possible with browser automation or certain Node.js operations:

kubectl logs -n openclaw deploy/openclaw | grep -i seccomp
# If blocked, use a custom seccomp profile instead of RuntimeDefault

Best Practices

  • Never relax security for convenience β€” add writable volume mounts instead of disabling read-only FS
  • Keep automountServiceAccountToken: false β€” OpenClaw doesn’t need K8s API access
  • Pin init container images β€” use busybox:1.37 not busybox:latest
  • Audit regularly β€” run kubectl get pods -o json | jq '.spec.securityContext'
  • Use PSA namespace labels β€” enforce restricted level cluster-wide
  • Set resource limits β€” prevent runaway agent sessions from starving other workloads

Key Takeaways

  • OpenClaw’s official manifests include 7 layers of pod security hardening
  • Read-only root filesystem with PVC + emptyDir for writable paths
  • Non-root UID 1000 with all Linux capabilities dropped
  • Service account token disabled β€” no K8s API access from the pod
  • Compliant with Kubernetes Restricted Pod Security Standards
  • Verify compliance with PSA namespace labels
#openclaw #pod-security #hardening #seccomp #non-root #security
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens