It seems like, While deleting the pv,pvc, I have messed up. I can delete the pvc without issues but I can not delete the pv that pv-protection in it. while deleting pv,pvc earlier, I have pressed CTRL+C since it was taking time to delete it and also deleted the storageclass before deleting the pvc. I don't remember the storage class that was used for creating the pvc.
In this post, it says, updating the pvc protection to null will help remove the pvc. But I had to delete the pv which has pv-protection. The below is the describe output of pv.
~/github/vault-operator# kubectl describe pv pv-hostpath
Name: pv-hostpath
Labels: type=local
Annotations: pv.kubernetes.io/bound-by-controller: yes
Finalizers: [kubernetes.io/pv-protection]
StorageClass: manual
Status: Terminating (lasts <invalid>)
Claim: poc-namespace/pvc-hostpath
Reclaim Policy: Retain
Access Modes: RWO
Capacity: 1Gi
Node Affinity: <none>
Message:
Source:
Type: HostPath (bare host directory volume)
Path: /kube
HostPathType:
Events: <none>
~/github/vault-operator# kubectl get pv,pvc
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/pv-hostpath 1Gi RWO Retain Terminating poc-namespace/pvc-hostpath manual 11d
question is, how can i delete the pv that is not deleted properly and what could be my issue.
In this scenario, you have a PVC (poc-namespace/pvc-hostpath) that is preventing your PV from being deleted. Delte the PVC, and you can delete the PV.
Generally speaking, the Reclaim Policy
of a PVC is delete
, by default, so when you delete a PVC, it automatically deletes the PV bound to it.
Your storageClass
probably was this one (or similar), from rancher. It is a hostPath
based one, meaning it maps your container volume to the host machine.