Helm V3 与 V2 版本架构变化较大,数据迁移也比较麻烦,官方为了解决数据迁移问题,提供一个 helm-2to3 工具,本文基于 helm-2to3 工具来迁移 V2 版本中的数据。
注意:Helm V2 升级 V3 版本,Kubernetes 集群中 Deployment、Service、Pod等都不会重新创建,所以迁移过程是不会影响线上在跑的服务。
安装 Helm V3 命令
下载 helm 最新 v3.2.3 版本
$ wget https://get.helm.sh/helm-v3.2.3-linux-amd64.tar.gz -O /tmp/helm-v3.2.3-linux-amd64.tar.gz
解压并移动到 /usr/local/bin/ 目录下
# 解压
$ tar xf /tmp/helm-v3.2.3-linux-amd64.tar.gz
# 移动
$ cd /tmp/linux-amd64
$ mv helm /usr/local/bin/helm3
安装 2to3 插件
一键安装
$ helm3 plugin install https://github.com/helm/helm-2to3
检查 2to3 插件是否安装成功
$ helm3 plugin list
NAME VERSION DESCRIPTION
2to3 0.5.1 migrate and cleanup Helm v2 configuration and releases in-place to Helm v3
迁移 Helm V2 配置
下面操作主要迁移:
1.Helm 插件
2.Chart 仓库
3.Chart starters
$ helm3 2to3 move config
检查 repo 和 plugin
# 检查 repo
$ helm3 repo list
NAME URL
stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
# 更新 repo
$ helm3 repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "stable" chart repository
# 检查 plugin
$ helm3 plugin list
NAME VERSION DESCRIPTION
2to3 0.5.1 migrate and cleanup Helm v2 configuration and releases in-place to Helm v3
迁移 Heml V2 Release
查看 2to3 插件中 convert 子命令选项
$ helm3 2to3 convert --help
migrate Helm v2 release in-place to Helm v3
Usage:
2to3 convert [flags] R