Master persistent storage in Kubernetes using Persistent Volumes, Persistent Volume Claims, and Storage Classes for stateful applications.
Define storage resources available in the cluster.
cat > persistent-volume.yaml << 'EOF'
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/pv
EOFkubectl apply -f persistent-volume.yamlkubectl get pvPersistent Volumes are cluster resources representing physical storage. Administrators provision PVs, users claim them with PVCs.
PV created with 1Gi capacity, STATUS shows Available, ACCESS MODES shows RWO.