如何将 PV 从一个 kubernetes 节点移动到另一个

问题描述 投票:0回答:1

我有一个使用 rancher.io/local-path 的 k8s 集群。 那里有PV


    $ kubectl describe pv pvc-979af6ff-3617-4707-8a2c-b6c4ac00043f
    Name:              pvc-979af6ff-3617-4707-8a2c-b6c4ac00043f
    Labels:            <none>
    Annotations:       pv.kubernetes.io/provisioned-by: rancher.io/local-path
    Finalizers:        [kubernetes.io/pv-protection]
    StorageClass:      local-path
    Status:            Bound
    Claim:             gitlab/gitlab-prometheus-server
    Reclaim Policy:    Delete
    Access Modes:      RWO
    VolumeMode:        Filesystem
    Capacity:          8Gi
    Node Affinity:     
      Required Terms:  
        Term 0:        kubernetes.io/hostname in [agent-1]
    Message:           
    Source:
        Type:          HostPath (bare host directory volume)
        Path:          /var/lib/rancher/k3s/storage/pvc-979af6ff-3617-4707-8a2c-b6c4ac00043f_gitlab_gitlab-prometheus-server
        HostPathType:  DirectoryOrCreate
    Events:            <none>

我想将该 PV 移动到另一个节点 agetn-5。我怎样才能做到这一点? 重要的一点是,有问题的 PV 是

rancher.io/local-path
提供的。

kubernetes rancher
1个回答
0
投票

一步完成是不可能的。

但是你可以:

  1. 访问PVC所在的K8s集群
  2. 创建一个 Deployment(或单个 Pod),将 PVC 安装在您喜欢的路径上(例如 /xyz)
  3. 奔跑
   kubectl -n NAMESPACE cp POD_NAME:/xyz /tmp/

本地复制/xyz文件夹的内容到/tmp路径

  1. 退出 K8s 集群

  2. 登录要迁移数据的K8s集群

  3. 创建新的 PVC

  4. 创建一个 Deployment(或 Single Pod),将 PVC 安装在您喜欢的路径上(示例 /new-xyz)

  5. 奔跑

   kubectl -n NAMESPACE cp /tmp/xyz/ POD_NAME:/new-xyz/

将本地内容复制到路径/new-xyz

© www.soinside.com 2019 - 2024. All rights reserved.