Share Claude Code configuration with PVC tmp copy
The entire PVC is mounted at /tmp/claude. A postStart command copies everything into the home directory. No init pod is required and there are no subPath limitations. Changes must be synced back manually before stopping the workspace.
The tmp copy flow:
-
The first workspace starts. The PVC mounts at
/tmp/claude(empty on first run). ThepostStartcommand copies configuration into/home/user/.claude/and/home/user/.claude.json. On first run, nothing is copied. -
You configure Claude Code — install plugins, add MCP servers, change settings. All writes go to the home directory, not the PVC.
-
Before stopping the workspace, you sync changes back to the PVC at
/tmp/claude. -
The second workspace starts. The
postStartcommand copies the saved configuration from the PVC into the home directory.
For a comparison with other approaches, see Persist Claude Code configuration in Che workspaces.
-
An active
kubectlsession with permissions to create PVCs in your namespace. See Overview of kubectl. -
Claude Code installed in the workspace container image.
-
For concurrent workspaces: a storage class that supports
ReadWriteMany(RWX) access mode, such as AWS EFS or NFS. Standard block storage (gp2, gp3) supports onlyReadWriteOnce(RWO).
-
Create a file
claude-config-pvc.yamlwith the following PVC definition:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: claude-config annotations: controller.devfile.io/mount-path: '[{"path":"/tmp/claude","subPath":"claude"}]' labels: controller.devfile.io/mount-to-devworkspace: 'true' spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi -
Apply the PVC to your namespace:
$ kubectl apply -f claude-config-pvc.yaml -n <your_namespace>
-
Add a
postStartcommand to your devfile to copy all configuration from the PVC into the home directory:commands: - id: init-claude-config exec: commandLine: | mkdir -p /home/user/.claude cp -a /tmp/claude/.claude/. /home/user/.claude/ 2>/dev/null || true cp /tmp/claude/.claude.json /home/user/.claude.json 2>/dev/null || true component: <editor_container> (1) events: postStart: - init-claude-config1 Replace with the name of your editor container component in the devfile. -
Start the workspace.
-
Before stopping the workspace, sync changes back to the PVC:
$ cp -a /home/user/.claude/. /tmp/claude/.claude/ && \ cp /home/user/.claude.json /tmp/claude/.claude.json
-
Start a workspace and configure Claude Code.
-
Sync changes back to the PVC.
-
Start a different workspace.
-
Verify that the Claude Code configuration from the first workspace is available.