Skip to content

Kubernetes PersistentVolume (PV)

In Kubernetes, a PersistentVolume (PV) is an abstraction that represents a piece of storage in the cluster.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]

The lifecycle of a PV is independent of any individual Pod that utilizes it.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md] This decoupling ensures that data persists and remains available even if the Pod using it is terminated, destroyed, or scaled.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]

Provisioning

PersistentVolumes can be provisioned through two primary methods:

  • Static Provisioning: An administrator manually creates PVs that represent actual storage resources (e.g., NFS, Node storage).^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]
  • Dynamic Provisioning: The cluster automatically creates a PV based on a [[PersistentVolumeClaim]] (PVC) that specifies a StorageClass.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]

Lifecycle and Status

Once a PersistentVolume is created, it goes through several phases:

  • Available: The volume is free and ready to be claimed.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]
  • Bound: The volume has been bound to a PersistentVolumeClaim.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]
  • Released: The claim has been deleted, but the resource has not yet been reclaimed by the cluster.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]
  • Failed: The automatic reclamation of the volume has failed.^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]

Reclaim Policy

When a PersistentVolume is released from its claim, the data on the volume is handled according to its reclaim policy^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]:

  • Retain: The volume requires manual reclamation.
  • Recycle: (Deprecated) Automatically wipes the volume (e.g., rm -rf /thevolume/*).^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]
  • Delete: Deletes both the PersistentVolume object and the associated underlying storage asset (e.g., AWS EBS, GCE PD).^[400-devops-06-kubernetes-k8s-ithelp-day20-readme.md]

Sources

  • 400-devops-06-kubernetes-k8s-ithelp-day20-readme.md