is it possible to recover the kubernetes lost state pvc

Viewed 1490

Today when I create the PVC and PV in kubernetes cluster v1.15.x, the kubernetes dashboard shows the PVC is in lost state, this is the error message of PVC:

this claim is in lost state.

this is my PVC define:

{
  "kind": "PersistentVolumeClaim",
  "apiVersion": "v1",
  "metadata": {
    "name": "zhuolian-report-mysql-pv-claim",
    "namespace": "dabai-uat",
    "selfLink": "/api/v1/namespaces/dabai-uat/persistentvolumeclaims/zhuolian-report-mysql-pv-claim",
    "uid": "3ca3425b-b2dc-4bd7-876f-05f8cbcafcf8",
    "resourceVersion": "106652242",
    "creationTimestamp": "2021-09-26T02:58:32Z",
    "annotations": {
      "pv.kubernetes.io/bind-completed": "yes"
    },
    "finalizers": [
      "kubernetes.io/pvc-protection"
    ]
  },
  "spec": {
    "accessModes": [
      "ReadWriteOnce"
    ],
    "resources": {
      "requests": {
        "storage": "8Gi"
      }
    },
    "volumeName": "nfs-zhuolian-report-mysql-pv",
    "volumeMode": "Filesystem"
  },
  "status": {
    "phase": "Lost"
  }
}

and this is my PV define in the same namespace:

{
  "kind": "PersistentVolume",
  "apiVersion": "v1",
  "metadata": {
    "name": "nfs-zhuolian-report-mysql-pv",
    "selfLink": "/api/v1/persistentvolumes/nfs-zhuolian-report-mysql-pv",
    "uid": "86291e89-8360-4d48-bae7-62c3c642e945",
    "resourceVersion": "106652532",
    "creationTimestamp": "2021-09-26T03:01:02Z",
    "labels": {
      "alicloud-pvname": "zhuolian-report-data"
    },
    "finalizers": [
      "kubernetes.io/pv-protection"
    ]
  },
  "spec": {
    "capacity": {
      "storage": "8Gi"
    },
    "nfs": {
      "server": "balabala.cn-hongkong.nas.balabala.com",
      "path": "/docker/mysql_zhuolian_report_data"
    },
    "accessModes": [
      "ReadWriteOnce"
    ],
    "claimRef": {
      "kind": "PersistentVolumeClaim",
      "namespace": "dabai-uat",
      "name": "zhuolian-report-mysql-pv-claim"
    },
    "persistentVolumeReclaimPolicy": "Retain",
    "mountOptions": [
      "vers=4.0",
      "noresvport"
    ],
    "volumeMode": "Filesystem"
  },
  "status": {
    "phase": "Available"
  }
}

what should I do do fix this problem? how to avoid problem like this? what may cause this problem?

1 Answers

try to delete the PVC's annoation will make the PVC rebind:

"annotations": {
   "pv.kubernetes.io/bind-completed": "yes"
},

I copied the PVC from another PVC and forget to remove the annotation.

Related