Prompt
I'm building a Kubernetes app that writes files to disk. What should I use for persistence?
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
For a Kubernetes app that writes files to disk, the usual answer is: use a PersistentVolumeClaim (PVC) backed by storage that matches your durability and performance needs.
What to use
1. PersistentVolumeClaim (PVC)
This is the Kubernetes-native way to request persistent storage for a Pod.
- Your app mounts the PVC as a volume.
- The data survives Pod restarts and rescheduling.
- The underlying storage can be:
- cloud disks like AWS EBS / GCE PD / Azure Disk
- network storage like NFS / Ceph / EFS / Filestore
- local disk, if you’re okay with node affinity and limited portability
2. Pick the right storage class
Use a StorageClass that fits your workload:
- Block storage: good for a single writer, databases, file-based apps
- Shared file storage: good if multiple Pods need to read/write the same files
- Local persistent storage: fastest, but tied to one node
Common choices by use case
If only one Pod needs the files
Use:
- PVC + block storage
- Example: AWS EBS, GCE Persistent Disk, Azure Disk
Good for:
- app data
- uploads
- caches that must survive restarts
- file-based state for one instance
If multiple Pods need the same files
Use:
- PVC with ReadWriteMany
- Typically backed by:
- NFS
- AWS EFS
- Azure Files
- GCP Filestore
Good for:
- shared uploads
- content repositories
- apps scaled horizontally
If you need maximum performance and can tolerate node coupling
Use:
- local persistent volume
Good for:
- high-performance workloads
- temporary-but-persistent local data
- specialized storage needs
What not to use
- emptyDir: data disappears when the Pod is deleted or moved
- writing directly into the container filesystem: also ephemeral
- hostPath in production: usually fragile and node-dependent
Typical recommendation
If you're unsure, start with:
- one Pod → PVC backed by block storage
- multiple Pods sharing files → PVC backed by RWX/shared storage
Example
A simple Pod mount looks like this:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-data
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: app
image: my-app:latest
volumeMounts:
- mountPath: /data
name: data
volumes:
- name: data
persistentVolumeClaim:
claimName: app-data
Rule of thumb
- Need persistence? Use a PVC
- Need sharing across Pods? Use RWX/shared storage
- Need speed and single-node usage? Consider local PV
If you want, I can also recommend the best storage option based on your cloud provider and whether you need one writer or multiple writers.