Persistent Volumes and Claims

A persistent volume (pv) is a storage abstraction used to retain data longer then the Pod using it. Pods define a volume of type persistentVolumeClaim (pvc) with various parameters for size and possibly the type of backend storage known as its StorageClass. The cluster then attaches the persistentVolume.

Kubernetes will dynamically use volumes that are available, irrespective of its storage type, allowing claims to any backend storage.

There are several phases to persistent storage.

Persistent Storage Phases

Provision

Provisioning can be from PVs created in advance by the cluster administrator, or requested from a dynamic source, such as the cloud provider.

Bind

Binding occurs when a control loop on the cp notices the PVC, containing an amount of storage, access request, and optionally, a particular StorageClass. The watcher locates a matching PV or waits for the StorageClass provisioner to create one. The PV must match at least the storage amount requested, but may provide more.

Use

The use phase begins when the bound volume is mounted for the Pod to use, which continues as long as the Pod requires.

Release

Releasing happens when the Pod is done with the volume and an API request is sent, deleting the PVC. The volume remains in the state from when the claim is deleted until available to a new claim. The resident data remains depending on the persistentVolumeReclaimPolicy.

Reclaim

The reclaim phase has three options:

  • Retain, which keeps the data intact, allowing for an administrator to handle the storage and data.

  • Delete tells the volume plugin to delete the API object, as well as the storage behind it.

  • The Recycle option runs an rm -rf /mountpoint and then makes it available to a new claim. With the stability of dynamic provisioning, the Recycle option is planned to be deprecated.

$ kubectl get pv

$ kubectl get pvc

Last updated