简体   繁体   English

在K8s集群之间使用PV移动状态集

[英]Moving Statefulsets with PV between K8s clusters

I am looking to migrate from old GKE clusters to the new Alias IP, however I need to migrate my statefulsets and their PersistentVolumeClaims to the new GKE clusters. 我希望从旧的GKE集群迁移到新的Alias IP,但是我需要将状态集及其PersistentVolumeClaims迁移到新的GKE集群。 I can't seem to find a good answer anywhere stating it's possible, but I imagine it should be as long as it's within the same region. 我似乎在任何地方都没有找到一个好的答案,说明它是可能的,但我想只要它在同一地区内就应该。 Both new/old k8s cluster still in the same GCP Project, and same Region. 两个新旧k8s群集仍位于同一GCP项目和同一区域中。

I've searched, but can't find an answer and I can't figure out how to recreate the statefulset without creating a new PV. 我进行了搜索,但找不到答案,也无法弄清楚如何在不创建新PV的情况下重新创建有状态集。

You might want to look into the Volume Snapshots and volume snapshot content direction. 您可能需要查看“ 卷快照”和“卷快照内容”方向。

Similar to how API resources PersistentVolume and PersistentVolumeClaim are used to provision volumes for users and administrators, VolumeSnapshotContent and VolumeSnapshot API resources are provided to create volume snapshots for users and administrators. 与使用API​​资源PersistentVolume和PersistentVolumeClaim为用户和管理员提供卷的方式类似,提供了VolumeSnapshotContent和VolumeSnapshot API资源为用户和管理员创建卷快照。

A VolumeSnapshotContent is a snapshot taken from a volume in the cluster that has been provisioned by an administrator. VolumeSnapshotContent是从管理员已配置的群集中的卷获取的快照。 It is a resource in the cluster just like a PersistentVolume is a cluster resource. 就像PersistentVolume是群集资源一样,它是群集中的资源。

A VolumeSnapshot is a request for snapshot of a volume by a user. VolumeSnapshot是用户对卷进行快照的请求。 It is similar to a PersistentVolumeClaim. 它类似于PersistentVolumeClaim。

Example of Volume Snapshot Contents: 卷快照内容示例:

apiVersion: snapshot.storage.k8s.io/v1alpha1 kind: VolumeSnapshotContent metadata:   name: new-snapshot-content-test spec:   snapshotClassName: csi-hostpath-snapclass   source:
    name: pvc-test
    kind: PersistentVolumeClaim   volumeSnapshotSource:
    csiVolumeSnapshotSource:
      creationTime:    1535478900692119403
      driver:          csi-hostpath
      restoreSize:     10Gi
      snapshotHandle:  7bdd0de3-aaeb-11e8-9aae-0242ac110002

Example of VolumeSnapshot: VolumeSnapshot示例:

apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshot
metadata:
  name: new-snapshot-test
spec:
  snapshotClassName: csi-hostpath-snapclass
  source:
    name: pvc-test
    kind: PersistentVolumeClaim

Volume Snapshot Alpha for Kubernetes was introduces in v1.12. v1.12中引入了Kubernetes的Volume Snapshot Alpha This feature allows creating/deleting volume snapshots, and the ability to create new volumes from a snapshot natively using the Kubernetes API. 该功能允许创建/删除卷快照,并能够使用Kubernetes API从本地创建快照中的新卷。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM