Reputation: 2277
I am trying to delete the data in a pv so that I can use a fresh data storage.
I've tried both kubectl delete pvc datastorage
and kubectl delete pv datastorage
- they removed the pv from my pod, but it was then attached again.
I'm using GKE, and I've also tried to delete the Storage from the console directly. However, my data is still there, and reflected within the running pods.
How do I delete the data from the storage?
Upvotes: 0
Views: 2913
Reputation: 361
Another way is to edit your yaml file and set your Reclaim Policy to Delete, the deletion will remove both the PersistentVolume object from Kubernetes, as well as the associated storage asset in the external infrastructure. For reference see this documentation on Reclaiming.
Upvotes: 0
Reputation: 1314
If a user deletes a PVC in active use by a Pod, the PVC is not removed immediately. PVC removal is postponed until the PVC is no longer actively used by any Pods. Also, if an admin deletes a PV that is bound to a PVC, the PV is not removed immediately. PV removal is postponed until the PV is no longer bound to a PVC. For further information, please see Storage Object in Use Protection
Having said that, it will be best to approach deletion in this order:
Upvotes: 2
Reputation: 2654
If your pod is part of a deployment or statefulset, delete it and on recreation you will get a new pvc.
Use the following
kubectl delete pods [name of pod]
kubectl get pvc
kubectl get pv
Upvotes: 2