k8s/labs/storage/hostpath-pv-pvc.yaml — Static PersistentVolume, PersistentVolumeClaim, and Pod wiring for hostPath-backed storage.k8s/labs/storage/nfs-pv-pvc.yaml — PV/PVC manifests using NFS for shared persistent storage.PV created and ready for binding. Not yet claimed by any PVC.
PV successfully bound to a PVC. Storage in use by Pod.
PVC deleted, but PV retains data. Awaiting reclaim action.
Reclaim policy executed: Retain, Delete, or Recycle (Deprecated).
Data preserved after PVC deletion. Manual cleanup required to reuse PV. Best for production data.
Automatically deletes PV and underlying storage resource. Default for dynamic provisioning.
Clears data (rm -rf) and makes PV available. Use Delete with dynamic provisioning instead.
Volume mounted read-write by single node. Multiple Pods on same node can use. Use: Databases, single-node apps.
Volume mounted read-only by multiple nodes. Use: Configuration files, static data sharing.
Volume mounted read-write by multiple nodes. Requires: NFS, CephFS, cloud file storage. Use: Shared logs, distributed apps.
apiVersion: v1
kind: PersistentVolume
metadata:
name: hostpath-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
hostPath:
path: /mnt/data
type: Directory
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hostpath-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: manual
apiVersion: v1
kind: Pod
metadata:
name: hostpath-pod
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: hostpath-volume
mountPath: /usr/share/nginx/html
volumes:
- name: hostpath-volume
persistentVolumeClaim:
claimName: hostpath-pvc
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: standard provisioner: ebs.csi.aws.com parameters: type: gp3 fsType: ext4 volumeBindingMode: WaitForFirstConsumer
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dynamic-pvc
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
apiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
containers:
- name: app
image: busybox
command: ['sh', '-c', 'sleep 3600']
volumeMounts:
- name: storage
mountPath: /data
volumes:
- name: storage
persistentVolumeClaim:
claimName: dynamic-pvc
kubectl get pvc (Status: Bound). Check PV: kubectl get pv. Verify Pod volume mount: kubectl exec -it <pod> -- ls /data