codegurukool.com · Free coding tutorials & online compiler

Home › Kubernetes Tutorial › Volumes and persistent storage

Volumes and persistent storage

Keep data when Pods restart.

Files inside a container disappear when it restarts. A PersistentVolumeClaim (PVC) asks the cluster for storage, and a Pod mounts it as a volume. The data survives Pod restarts and rescheduling.

Example code

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Run this code in the online editor

← Use ConfigMaps and Secrets in a PodIngress →