*RECLAIMING A PV* this is a scenario I've run into and which wasn't covered in . . .


this is a scenario I’ve run into and which wasn’t covered in the course and I’m pretty sure others have as well. You have a PV that is bound to a PVC and you then want to

• detach it from the PVC because you created the PVC in the wrong namespace
• reuse the PV because the pod that was using it is no longer using it
in either case, the solution is easy. Just edit the pv:

$ k edit pv pv-1

and then delete the claimRef section highlighted below. You’ll then be able to bind it to another PVC

why not just delete the pvc from the wrong namespace?

Deleting the PVC doesn’t make the PV available. You have to manually edit the PV to make it usable again

Daniel Zilberman:
@OE to be fair, that behavior (releasing PV from PVC that “claimed” some of its resources) is also controlled by reclaim policy, as illustrated here: https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/. Perhaps “Recycle” reclaim policy would work for your scenario? I recall that in the course labs we had to first delete pod that uses PVC as a Volume and then delete PVC itself so that PV resource was available again…

Even when you delete the pod + PVC, if the policy is recycle, the PV is not available. Test it out and tell me. But from what I looked at it, you had to manually remove the claim even after deleting the PVC + pod