Member-only story
How To Restore “Released” PV’s in Longhorn Kubernetes
Took me a while to figure this out, so sharing it here to save you some time
When using Longhorn with a StorageClass, it’s typically recommended to set the ReclaimPolicy of the StorageClass to “Retain” instead of “Delete” (which is the default setting).
This helps to ensure that if a PersistentVolumeClaim (PVC) is deleted on accident, the PersistentVolume (PV) that the StorageClass automatically provisioned won’t be deleted automatically along with it’s data.
However, while this sounds good on paper, what I came to realise when using Longhorn is, even though the PersistentVolume (PV) stays around after it’s PersistentVolumeClaim (PVC) get’s deleted, it actually remains in a “Released” state.
This means any new PersistentVolumeClaim you create in place of the old PersistentVolumeClaim, will not be able to access the “Released” PersistentVolume’s data.
Instead, the StorageClass will provision a new PersistentVolume and you end up with 2 PVs but only 1 PVC.
It’s a bit of a mess.
Here’s an example output of kubectl get pv
to show you what I mean (I know the PV’s are named like “pvc-followed-by-random-hash” which can be a bit confusing, but that’s just how…