安装velero参考这里:安装velero实现集群迁移
从旧集群导出需要的crd资源清单yaml文件
kubectl get crd routetables.gateway.solo.io -oyaml >routetables.gateway.solo.io.yaml kubectl get crd upstreamgroups.gloo.solo.io -oyaml >upstreamgroups.gloo.solo.io.yaml kubectl get crd authconfigs.enterprise.gloo.solo.io -oyaml >authconfigs.enterprise.gloo.solo.io.yaml kubectl get crd ratelimitconfigs.ratelimit.solo.io -oyaml >ratelimitconfigs.ratelimit.solo.io.yaml kubectl get crd virtualhostoptions.gateway.solo.io -oyaml >virtualhostoptions.gateway.solo.io.yaml kubectl get crd routeoptions.gateway.solo.io -oyaml >routeoptions.gateway.solo.io.yaml
旧的集群上执行备份
miniopodname=`kubectl -n zadig get pod -l app=minio|grep -v NAME|awk '{print $1}'` kubectl -n zadig annotate pod/$miniopodname backup.velero.io/backup-volumes=kr-minio --overwrite kubectl -n zadig annotate pod/kr-mysql-0 backup.velero.io/backup-volumes=data-kr-mysql-0 --overwrite kubectl -n zadig annotate pod/kr-mongodb-0 backup.velero.io/backup-volumes=data-kr-mongodb-0 --overwrite velero backup create zadig-20230717 --include-namespaces zadig
可以看到备份进度
新的集群上(如果存储类发生变化需要创建以下文件,因为我是从nfs-storage迁移到cephfs-sc
)
创建crd资源文件,就是我们第一步导出的yaml
kubectl create -f routetables.gateway.solo.io.yaml
......
vi change-storage-class-config.yaml apiVersion: v1 kind: ConfigMap metadata: name: change-storage-class-config namespace: velero labels: velero.io/plugin-config: "" velero.io/change-storage-class: RestoreItemAction data: nfs-storage: cephfs-sc
kubectl create -f change-storage-class-config.yaml
velero restore create --from-backup zadigbak