Sunday, 4 July 2021

PVC in terminating state

Referencee:https://veducate.co.uk/kubernetes-pvc-terminating/


 I still had errors performing deployment, till I released that although I previously was able to delete my PV, my PVC was still in a terminating state. Also realised that I need to be in the right project to see PVC (unless you used --all-namespaces):

[root@okd4-services okd4_files]# oc get pv

NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                             STORAGECLASS   REASON   AGE

registry-pv   100Gi      RWX            Retain           Bound    openshift-image-registry/image-registry-storage                           4h34m


[root@okd4-services ~]# oc get pvc

No resources found in wordpress-test namespace.


[root@okd4-services ~]# oc get pvc --all-namespaces
NAMESPACE                  NAME                     STATUS        VOLUME        CAPACITY   ACCESS MODES   STORAGECLASS   AGE
openshift-image-registry   image-registry-storage   Terminating   registry-pv   100Gi      RWX                           152d
[root@okd4-services ~]# oc get pvc --all-namespaces^C
[root@okd4-services ~]# kubectl get volumeattachment --all-namespaces
No resources found



[root@okd4-services ~]# oc project
Using project "wordpress-test" on server "https://api.lab.okd.local:6443".
[root@okd4-services ~]# oc project openshift-image-registry
Now using project "openshift-image-registry" on server "https://api.lab.okd.local:6443".



[root@okd4-services ~]# kubectl patch pvc image-registry-storage -p '{"metadata":{"finalizers":null}}'
persistentvolumeclaim/image-registry-storage patched
[root@okd4-services ~]# oc get pvc --all-namespaces
No resources found
[root@okd4-services ~]# oc get pv
NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS     CLAIM                                             STORAGECLASS   REASON   AGE
registry-pv   100Gi      RWX            Retain           Released   openshift-image-registry/image-registry-storage                           23h


After that I went thru the steps for deleting PV and recreating it.

Saturday, 3 July 2021

Cannot delete pv

 Hang when trying to delete PV:


[root@okd4-services ~]# oc get pv

NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS        CLAIM                                             STORAGECLASS   REASON   AGE

registry-pv   100Gi      RWX            Retain           Terminating   openshift-image-registry/image-registry-storage                           151d

[root@okd4-services ~]# kubectl delete pv registry-pv --grace-period=0 --force

warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.

persistentvolume "registry-pv" force deleted





^C




Solution:

[root@okd4-services ~]# kubectl describe pv registry-pv
Name:            registry-pv
Labels:          <none>
Annotations:     pv.kubernetes.io/bound-by-controller: yes
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:
Status:          Terminating (lasts 13h)
Claim:           openshift-image-registry/image-registry-storage
Reclaim Policy:  Retain
Access Modes:    RWX
VolumeMode:      Filesystem
Capacity:        100Gi
Node Affinity:   <none>
Message:
Source:
    Type:      NFS (an NFS mount that lasts the lifetime of a pod)
    Server:    192.168.1.210
    Path:      /var/nfsshare/registry
    ReadOnly:  false
Events:        <none>

[root@okd4-services ~]# kubectl edit pv registry-pv
persistentvolume/registry-pv edited


i.e. https://stackoverflow.com/questions/55672498/kubernetes-clustsr-stuck-on-removing-pv-pvc/55672788

kubectl edit pv (pv name)

FIND the following

finalizers: - kubernetes.io/pv-protection

AND delete it. Then exit and: kubectl delete pv (pv name) --grace-period=0 --force


PVC in terminating state

Referencee:https://veducate.co.uk/kubernetes-pvc-terminating/  I still had errors performing deployment, till I released that although I pre...