Kubernetes PV在Retain策略Released状态下重新分配到PVC恢复数据

原由:在使用helm update stable/sonatype-nexus从1.6版本更新到1.13版本后,出现PVC删除,重新创建PVC的情况,好在原来PV为Retain。故研究下Retain的PV怎么恢复数据。

此为我创建的一个PV,后端存储为nfs
apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"name":"custom-pv0001"},"spec":{"accessModes":["ReadWriteOnce"],"capacity":{"storage":"20Gi"},"nfs":{"path":"/test1","server":"10.88.10.253"}}}
    pv.kubernetes.io/bound-by-controller: "yes"
  creationTimestamp: "2019-07-23T12:54:04Z"
  finalizers:
  - kubernetes.io/pv-protection
  name: custom-pv0001
  resourceVersion: "4623345"
  selfLink: /api/v1/persistentvolumes/custom-pv0001
  uid: f3a96793-ad48-11e9-b47f-525400b97587
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 20Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: prometheus-server
    namespace: monit
    resourceVersion: "4623328"
    uid: 0a1d3fd5-ad49-11e9-b47f-525400b97587
  nfs:
    path: /test1
    server: 10.88.10.253
  persistentVolumeReclaimPolicy: Retain
只需要删除其中claimRef段就可以看到状态为可用了
claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: prometheus-server
    namespace: monit
    resourceVersion: "4623328"
    uid: 0a1d3fd5-ad49-11e9-b47f-525400b97587
此条目发表在kubernetes分类目录。将固定链接加入收藏夹。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注