Prompt
I'm building on Kubernetes and need files to survive pod restarts, what do you recommend?
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
If you need files to survive pod restarts in Kubernetes, the usual recommendation is:
Use a PersistentVolumeClaim (PVC)
A PVC gives your pod durable storage that lives independently of the pod, so data remains after the pod is restarted, rescheduled, or replaced.
Typical setup
- Create a PersistentVolumeClaim
- Mount it into your Pod/Deployment
- Write files to that mounted path
Example:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
And in your Deployment:
volumes:
- name: data
persistentVolumeClaim:
claimName: app-data
containers:
- name: app
image: your-image
volumeMounts:
- mountPath: /data
name: data
What storage to choose
Depends on your workload:
- Single pod / one writer:
ReadWriteOncePVC is usually fine. - Multiple pods need shared access: use
ReadWriteManystorage if your cloud/provider supports it, or use network file storage like NFS, EFS, Azure Files, Filestore, etc. - High performance / database-like workloads: prefer block storage via PVC, but make sure the app handles persistence correctly.
Important note
Avoid storing important files only inside the container filesystem, because container layers are ephemeral. If the pod dies, those files are typically lost.
If you need something else
- Configuration that should survive but isn’t app data: use a ConfigMap or Secret, not a PVC.
- Logs: usually ship them to stdout/stderr and use a logging system, not local files.
If you want, I can recommend the best storage option based on your cloud provider and whether you need single-writer or shared storage.