I created the following persistent volume by calling
kubectl create -f nameOfTheFileContainingTheFollowingContent.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-monitoring-static-content
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/some/path"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-monitoring-static-content-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: ""
resources:
requests:
storage: 100Mi
After this I tried to delete the pvc. But this command stuck.
when calling kubectl describe pvc pv-monitoring-static-content-claim
I get the following result
Name: pv-monitoring-static-content-claim
Namespace: default
StorageClass:
Status: Terminating (lasts 5m)
Volume: pv-monitoring-static-content
Labels: <none>
Annotations: pv.kubernetes.io/bind-completed=yes
pv.kubernetes.io/bound-by-controller=yes
Finalizers: [foregroundDeletion]
Capacity: 100Mi
Access Modes: RWO
Events: <none>
And for kubectl describe pv pv-monitoring-static-content
Name: pv-monitoring-static-content
Labels: <none>
Annotations: pv.kubernetes.io/bound-by-controller=yes
Finalizers: [kubernetes.io/pv-protection foregroundDeletion]
StorageClass:
Status: Terminating (lasts 16m)
Claim: default/pv-monitoring-static-content-claim
Reclaim Policy: Retain
Access Modes: RWO
Capacity: 100Mi
Node Affinity: <none>
Message:
Source:
Type: HostPath (bare host directory volume)
Path: /some/path
HostPathType:
Events: <none>
There is no pod running that uses the persistent volume. Could anybody give me a hint why the pvc and the pv are not deleted?
If PV still exists it may be because it has ReclaimPolicy set to Retain in which case it won't be deleted even if PVC is gone. From the docs:
In my case, as long as I delete the pod associated to both
pv
andpvc
, thepv
andpvc
in terminating status are gone