Lifecycle of Persistent Volumes
Fleetinglifecycle of persistent volumes in kubernetes.
Dynamic
- A PVC is created
- A Pod is created, that mounts a PVC
- mounting the PVC creates the associated PV, using the storageclass to know how
- when the pod is deleted, the PV remains, as it is bound to the PVC
- when the pvc is deleted, its deletion waits for all the pods that mount it before really deleting it.
- when the pvc is deleted, the associated pv is deleted
In other terms, a dynamic PVC is like a delayed PV.
Static
The PV is create prior to creating the PVC and is bound to it when the PVC is created.
When the PVC is deleted, the PV is deleted.
The reclaim policy
When the PV is deleted, the real data is either
- kept, when the reclaim policy is Retain
- deleted, when the reclaim policy is Delete
See https://kubernetes.io/docs/concepts/storage/persistent-volumes/
Currently, volumes can either be Retained, Recycled, or Deleted.
For volume plugins that support the Delete reclaim policy, deletion removes both the PersistentVolume object from Kubernetes, as well as the associated storage asset in the external infrastructure, such as an AWS EBS, GCE PD, Azure Disk, or Cinder volume