如何手动恢复 PV [英] How to manual recover a PV

查看:26
本文介绍了如何手动恢复 PV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据官方文档 https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/ 使用保留"策略可以手动恢复 PV.这实际上意味着什么?是否有一种工具可以让我从保留的"PV 中读取数据并将其写入另一个 PV,或者这是否意味着您可以安装该卷手册以获得访问权限?

according to the official docs https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/ with the "Retain" policy a PV can be manually recovered . What does that actually mean and is there a tool how I can read the data from that "retained" PV and write it into to another PV , or does it mean you can mount that volume manual in order to gain access ?

推荐答案

手动恢复卷的过程如下.

The process to manually recover the volume is as below.

即使删除了PVC,您也可以使用相同的PV与数据一起挂载到不同的pod(PV必须存在,如果storageclass的回收策略为Retain,则通常会存在)

You can use the same PV to mount to different pod along with the data even after the PVC is deleted (PV must exist, will typically exist if the reclaim policy of storageclass is Retain)

验证 PV 处于释放状态.(即目前没有 pvc 声称它)

Verify that PV is in released state. (ie no pvc has claimed it currently)

 ➜  ~ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS     CLAIM                     STORAGECLASS   REASON   AGE
pvc-eae6acda-59c7-11e9-ab12-06151ee9837e   16Gi       RWO            Retain           Released   default/dhanvi-test-pvc   gp2                     52m

编辑 PV(kubectl edit pv pvc-eae6acda-59c7-11e9-ab12-06151ee9837e)并删除 spec.claimRef 部分.PV 声明将取消设置,如下所示.

Edit the PV (kubectl edit pv pvc-eae6acda-59c7-11e9-ab12-06151ee9837e) and remove the spec.claimRef part. The PV claim would be unset like below.

 ➜  ~ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
pvc-eae6acda-59c7-11e9-ab12-06151ee9837e   16Gi       RWO            Retain           Available           gp2                     57m

然后使用 PVC 声明 PV,如下所示.

Then claim the PV using PVC as below.

---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: dhanvi-test-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 16Gi
  volumeName: "pvc-eae6acda-59c7-11e9-ab12-06151ee9837e"

可以在如下的 Pod 中使用.

Can be used in the pods as below.

volumes:
- name: dhanvi-test-volume
  persistentVolumeClaim:
    claimName: dhanvi-test-pvc

更新:批量克隆可能有帮助 https://kubernetes.io/blog/2019/06/21/introducing-volume-cloning-alpha-for-kubernetes/

Update: Volume cloning might help https://kubernetes.io/blog/2019/06/21/introducing-volume-cloning-alpha-for-kubernetes/

这篇关于如何手动恢复 PV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆