Update Persistent Volume for a PVC
Fix a Persistent Volume binding to the wrong Persistent Volume
This run book will guide you through the process of fixing a Persistent Volume (PV) that has been incorrectly bound to the wrong Persistent Volume Claim (PVC).
This run book works for both ReadWriteMany
and ReadWriteOnce
Persistent Volumes (for example: NFS and Block Storage).
Back-up data
Since we are dealing with data, make sure you have created a back-up before modifing any persistent volume or persistent volume claim resource.
Follow the steps below to resolve the issue:
Situation
The PersistentVolumeClaim:
The PersistentVolumes:
The PVC is bound to PV pvc-98bd91e6-948d-4518-88d1-b9fed2779cc4
but needs to be bound to pvc-09636c84-ad97-4921-9af5-8997bc96323b
.
Create new PVC yaml file
Create a new YAML file with the correct PVC, referencing the right PV in the last line. You can use the existing PVC output as a reference:
For example:
Remove Claim Reference from the PV
Edit the PV and remove the entire claimRef block, then save the file:
This looks something like below.
Remove this whole claimRef block and save file.
The new STATUS of the PV should now be Available
instead of Released
:
Remove the old PVC
The PVC that is pointing to the wrong PV needs to be removed. If this PVC is mounted into a pod, the pod must be stopped to free the PVC:
If the PVC remains in the Deleting
status, it is likely still mounted. Stop the pod where it is mounted.
Create new PVC
Deploy the correct PVC you created in step 2. Ensure you are in the right namespace when deploying:
Verify the changes:
The newly created PVC should now be bound to the correct PV. The original PV is released but still exists due to the "Retain" policy, ensuring that data is not lost until the PV is manually removed.
Start application and check data
Test the application by starting and verify the right data exists in the right place.
Last updated on