Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

How to Fix a Failed PV in OpenShift Cluster

How to Fix a Failed PV in OpenShift Cluster
Image : https://premierevanlines.com
There are several cases a PV (PersistentVolume) appear as Failed in OpenShift or Kubernetes cluster. Once of the reason is wrong ClaimRef by which PV will mark as claimed but actually not in use. Let’s see one example.
# oc get pv |grep lv-1g-110
lv-1g-110                 1Gi        RWO,ROX,RWX   Recycle         Failed      newproject/postgresql-test-dep                                                                               26d

From above snippet we can understand that, the PV lv-1g-110 is claimed by a PVC (PersistentVolumeClaim) named postgresql-test-dep and this is under project newproject . So let us check that PVC details.

# oc get pvc -n newproject | grep postgresql-test-dep
# oc get pvc -n newproject | grep lv-1g-110
#

Aah ! now we got confused; there is no such PVC called postgresql-test-dep or anything with lv-1g-110. Means, lv-1g-110 is stuck with some wrong claim. Let us see what is holding inside PV config.

# oc describe pv lv-1g-110 |grep Claim
Claim:          newproject/postgresql-test-de

No wonder, we can see the PV got a ClaimRef for a PVC which doesn’t exist at all ! Let’s remove this.

Method 1 : Using oc edit

oc edit and remove those ClaimRef lines.

# oc edit pv lv-1g-110

Then remove below lines and save it.

claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: postgresql-test-de
    namespace: newproject
    resourceVersion: "569221692"
    uid: 44aa4a1a-e3fd-11e8-83ad-65efe91e200

Method 2 : Using oc patch

# oc patch pv/lv-1g-110 --type json -p '[{ "op": "remove", "path": "/spec/claimRef" }]'

Now we check the pv status.

# oc get pv |grep lv-5g-293
lv-1g-110                 1Gi        RWO,ROX,RWX   Recycle         Available                                                                                                                                8

That’s all; our pv is Available for next claim.

Gineesh Madapparambath

Gineesh Madapparambath

Gineesh Madapparambath is the founder of techbeatly. He is the co-author of The Kubernetes Bible, Second Edition and the author of Ansible for Real Life Automation. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (Read more: iamgini.com)


Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

How to setup SSH key based authentication

How to setup SSH key based authentication

This method is more secure than password-based access since the authentication happens using private and public key pair values.

Ansible

Ansible Nested Loop with List and Dictionary

Ansible loops are simple and powerful with mixed data. You will sure say “awesome” when you realize the easiness with loops. During our technical …

AWS Transformation Day Kuala Lumpur

AWS Transformation Day Kuala Lumpur

AWS is arranging the AWS Transformation Day Kuala Lumpur 2018 to discover first-hand the transformative opportunities of the cloud for your …

OpenShift Container Platform 3.11 Installation Documents

OpenShift Container Platform 3.11 Installation Documents

Since OCP 3.11 is available now, you may refer below documents for OpenShift Container Platform 3.11 Installation on different infrastructure or …

Implementing Ansible Roles

Implementing Ansible Roles

In a production environment, we will have hundreds and thousands of different types machines to handle. Hence the type of operations and …

Running Ansible Ad-Hoc commands

Running Ansible Ad-Hoc commands

We have already run few ad-hoc command to list down the hosts in earlier sections. See all parts of Automation with Ansible Guides here Let’s...