https://www.cnblogs.com/weifeng1463/p/11490399.html
[rancher@rmaster01 ~]$ kubectl -n rbd-system patch pvc rbd-hub -p '{"metadata":{"finalizers":null}}'
persistentvolumeclaim/rbd-hub patched
[rancher@rmaster01 ~]$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASONAGE
pvc-9dabb03b-fcdb-4730-8b5d-122210374fda 1Gi RWX Delete Terminating rbd-system/rbd-hub longhorn6h31m
[rancher@rmaster01 ~]$ kubectl patch pv pvc-9dabb03b-fcdb-4730-8b5d-122210374fda -p '{"metadata":{"finalizers":null}}'
persistentvolume/pvc-9dabb03b-fcdb-4730-8b5d-122210374fda patched
[rancher@rmaster01 ~]$ kubectl get pv
No resources found
[rancher@rmaster01 ~]$
[rancher@rmaster01 ~]$ kubectl -n rbd-system get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-62201dfc-96d5-4c15-b2cb-088bdf69f6d5 500Gi RWO Retain Terminating 54c2eb3ff2e84304aeee4cb2c2382e97/manual1-gr939832-0 rainbondsssc 157m
[rancher@rmaster01 ~]$ kubectl -n rbd-system patch pv pvc-62201dfc-96d5-4c15-b2cb-088bdf69f6d5 -p '{"metadata":{"finalizers":null}}'
persistentvolume/pvc-62201dfc-96d5-4c15-b2cb-088bdf69f6d5 patched
[rancher@rmaster01 ~]$ kubectl -n rbd-system get pv
No resources found
[rancher@rmaster01 ~]$
参考信息:
This happens when persistent volume is protected. You should be able to cross verify this:
Command:
kubectl describe pvc PVC_NAME | grep Finalizers
Output:
Finalizers: [kubernetes.io/pvc-protection]
You can fix this by setting finalizers to null using kubectl patch:
kubectl patch pvc PVC_NAME -p ‘{“metadata”:{“finalizers”: []}}’ —type=merge
[root@test-dev-master01 ~]# kubectl patch pvc test-es01 -p '{"metadata":{"finalizers":null}}' -n xitu-test
persistentvolumeclaim/test-es01 patched