Why Persistent Storage?
Containers are ephemeral — when a Pod restarts, its filesystem resets. Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) let your applications on a Breeze store data that survives Pod restarts and rescheduling.
Key Concepts
- PersistentVolume (PV) — a piece of storage provisioned in the cluster
- PersistentVolumeClaim (PVC) — a request for storage by a Pod
- StorageClass — defines how storage is dynamically provisioned
Check Available Storage Classes
kubectl get storageclassK3s includes a local-path StorageClass by default.
Create a PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-data
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: 5Gikubectl apply -f pvc.yaml
kubectl get pvcUse the PVC in a Pod
apiVersion: v1
kind: Pod
metadata:
name: app-with-storage
spec:
containers:
- name: app
image: nginx:alpine
volumeMounts:
- name: data
mountPath: /usr/share/nginx/html
volumes:
- name: data
persistentVolumeClaim:
claimName: app-dataAccess Modes
- ReadWriteOnce (RWO) — single node read-write
- ReadOnlyMany (ROX) — multiple nodes read-only
- ReadWriteMany (RWX) — multiple nodes read-write
Managing Volumes
kubectl get pv
kubectl describe pvc app-data
kubectl delete pvc app-dataAlways set appropriate storage sizes and back up persistent data regularly on your Breeze.