Why Cannot I Delete a PV or PVC Using the kubectl delete Command?
Symptom
An existing PV or PVC cannot be deleted by running the kubectl delete command and it remains in the terminating state.
Possible Causes
To prevent data loss caused by mis-deletion of PVs or PVCs, Kubernetes provides a data protection mechanism. A PV or PVC cannot be directly deleted using the kubectl delete command.
Solution
Run the kubectl patch command first to remove the protection mechanism and then delete the PV or PVC.
If you have run kubectl delete to delete a PV or PVC, the PV or PVC remains in the terminating state. It will be directly deleted after you run the kubectl patch command.
- Run the following command to delete a PV:
kubectl patch pv <pv-name> -p '{"metadata":{"finalizers":null}}' kubectl delete pv <pv-name>
- Run the following command to delete a PVC:
kubectl patch pvc <pvc-name> -p '{"metadata":{"finalizers":null}}' kubectl delete pvc <pvc-name>
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot