Managed Kubernetes
Latest
Frequently Asked Questions
Solutions
How Tos
Internal Only
Templates
Powered By

Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Recover Persistent Volumes from "Terminating" State
Copy Markdown
Open in ChatGPT
Open in Claude
Problem
- Accidentally performed delete operation on PV instead of PVC.
Bash
xxxxxxxxxx$ kubectl delete pv --all -n <Namespace>- All PV's across the Cluster are in Terminating state. Need to recover or set it back to "Bound" state.
Environment
- Platform9 Managed Kubernetes - All versions
]Cause
- Default behaviour having the annotation kubernetes.io/pv-protection, it doesn't let controllers to delete PV till the time it is Bound with a PVC.
Resolution
As a workaround, the below operations can be carried out to try recover the PV back to bound state.
- Take the backup of the existing PV
Bash
xxxxxxxxxxkubectl get pv <pvname> -o yaml > pv.yaml - Edit the existing PV and delete the spec.claimRef section. This will delete the PV completely. The PVC would be in lost status initially when the PV is deleted
Bash
xxxxxxxxxx$ kubectl edit pv <pvname> - Edit the backed up PV YAML and delete the metadata.deletionTimestamp line.
Bash
xxxxxxxxxx$ vi pv.yaml and delete the "metadata.deletionTimestamp" line- Create the PV and wait for the status to be updated. After recreating the PV, the PVC should be back in bound status.
Bash
xxxxxxxxxx$ kubectl create -f pv.yaml$ kubectl get pv$ kubectl get pvc -n <namespace>VariableType to search · ESC to discard
GlossaryType to search · ESC to discard
InsertType to search · ESC to discard
No matches
Last updated on
Was this page helpful?
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message