GitOps for OpenClaw Workspaces on Kubernetes
Manage OpenClaw agent workspaces (SOUL.md, skills, memory) with GitOps using Flux or ArgoCD, enabling version-controlled AI persona management on.
π‘ Quick Answer: Store your OpenClaw workspace files (SOUL.md, AGENTS.md, skills/, TOOLS.md) in a Git repo. Use a Kubernetes CronJob or init container with
git pullto sync changes, or use Flux/ArgoCD to manage ConfigMaps containing workspace files. Changes to SOUL.md in Git automatically update the agentβs persona.Key concept: Workspace files define who your agent is (SOUL.md), how it behaves (AGENTS.md), and what it can do (skills/). Version-controlling these enables auditable, rollback-able AI persona management.
Gotcha: Donβt version-control
memory/files or session state β those are runtime data that should stay in PVCs.
The Problem
- Agent persona changes (SOUL.md edits) are lost if not tracked
- Multiple environments (dev/staging/prod) need consistent agent configuration
- Rolling back a bad persona change requires manual intervention
- Skills and workspace files need a review process before deployment
The Solution
Store workspace files in Git and sync them to Kubernetes using GitOps patterns.
Architecture Overview
flowchart LR
subgraph git["Git Repository"]
SOUL["SOUL.md"]
AGENTS["AGENTS.md"]
SKILLS["skills/"]
TOOLS["TOOLS.md"]
end
subgraph k8s["βΈοΈ Kubernetes"]
SYNC["Git Sync<br/>Sidecar"]
GW["OpenClaw<br/>Gateway"]
PVC["PVC<br/>Runtime State"]
end
git -->|"git pull"| SYNC
SYNC --> GW
GW --> PVCOption 1: Git-Sync Sidecar
# openclaw-gitsync.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: openclaw-gateway
namespace: openclaw
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: openclaw
template:
spec:
initContainers:
- name: git-sync-init
image: registry.k8s.io/git-sync/git-sync:v4.3.0
args:
- "--repo=https://github.com/yourorg/openclaw-workspace.git"
- "--root=/workspace"
- "--one-time"
volumeMounts:
- name: workspace
mountPath: /workspace
env:
- name: GITSYNC_USERNAME
valueFrom:
secretKeyRef:
name: git-credentials
key: username
- name: GITSYNC_PASSWORD
valueFrom:
secretKeyRef:
name: git-credentials
key: token
containers:
- name: openclaw
image: registry.example.com/openclaw:v1
volumeMounts:
- name: workspace
mountPath: /home/node/.openclaw/workspace
subPath: workspace
- name: state
mountPath: /home/node/.openclaw
resources:
requests:
cpu: 250m
memory: 512Mi
- name: git-sync
image: registry.k8s.io/git-sync/git-sync:v4.3.0
args:
- "--repo=https://github.com/yourorg/openclaw-workspace.git"
- "--root=/workspace"
- "--period=60s"
volumeMounts:
- name: workspace
mountPath: /workspace
volumes:
- name: workspace
emptyDir: {}
- name: state
persistentVolumeClaim:
claimName: openclaw-stateOption 2: ConfigMap-Based (Simple)
# openclaw-workspace-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: openclaw-workspace
namespace: openclaw
data:
SOUL.md: |
# My AI Assistant
Be helpful, concise, and technically accurate.
Have opinions. Don't be a sycophant.
Use code blocks for commands and YAML.
AGENTS.md: |
# Agent Configuration
Read SOUL.md every session. Update memory files.
Be resourceful before asking questions.
TOOLS.md: |
# Tools Notes
- Preferred TTS voice: Nova
- Default timezone: America/New_YorkGit Repository Structure
openclaw-workspace/
βββ SOUL.md
βββ AGENTS.md
βββ USER.md
βββ TOOLS.md
βββ IDENTITY.md
βββ HEARTBEAT.md
βββ skills/
β βββ weather/
β β βββ SKILL.md
β βββ discord/
β βββ SKILL.md
βββ README.md # Not synced β repo docs onlyCommon Issues
Issue 1: Git-sync overwrites runtime changes
# OpenClaw may modify workspace files (memory, notes)
# Solution: Only sync specific files, not the entire directory
# Or use a merge strategy instead of hard resetIssue 2: ConfigMap size limit
# ConfigMaps have a 1MB limit
# For large workspaces with many skills, use git-sync insteadBest Practices
- Version control SOUL.md β Track persona changes with commit history
- PR reviews for persona changes β Treat SOUL.md edits like code reviews
- Donβt sync memory/ β Runtime memory files belong in PVCs
- Use branches for environments β
mainβ prod,stagingβ staging agent - Sync period of 60s β Fast enough for updates, not too aggressive
Key Takeaways
- GitOps for AI personas enables auditable, version-controlled agent management
- Git-sync sidecar continuously pulls workspace changes from Git
- ConfigMaps work for simple setups but have size limits
- Never version-control memory or sessions β those are runtime state
- PR-based workflow adds review gates to persona and skill changes
π Get All 100+ Recipes in One Book
Stop searching β get every production-ready pattern with detailed explanations, best practices, and copy-paste YAML.
π Deepen Your Skills β Hands-on Courses
Build and deploy AI agents with OpenClaw β hands-on course with real-world projects.
Start Learning βAutomate Kubernetes node configuration and cluster bootstrapping with Ansible.
Start Learning βCourses by CopyPasteLearn.com β Learn IT by Doing
Want More Kubernetes Recipes?
This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.