Helm V2 迁移到 V3 版本
-- :: Mr-Liuqx 阅读数 63更多 分类专栏: kubernetes 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/qq_34857250/article/details/100917486 helm3 发布了 应该学习一下的 不过自己不会写helm文件呢.
文章目录
安装 Helm V3
$ helm3 version
version.BuildInfo{Version:"v3.0.0-beta.3", GitCommit:"5cb923eecbe80d1ad76399aee234717c11931d9a", GitTreeState:"clean", GoVersion:"go1.12.9"}
$ helm2 repo list
NAME URL
stable http://mirror.azure.cn/kubernetes/charts/
local http://127.0.0.1:8879/charts
$ helm3 repo list
Error: no repositories to show
HELM-2TO3 插件
$ helm3 plugin install https://github.com/helm/helm-2to3
Downloading and installing helm-2to3 v0.1.1 ...
https://github.com/helm/helm-2to3/releases/download/v0.1.1/helm-2to3_0.1.1_darwin_amd64.tar.gz
Installed plugin: 2to3
确认是否安装成功
$ helm3 plugin list
NAME VERSION DESCRIPTION
2to3 0.1.1 migrate Helm v2 configuration and releases in-place to Helm v3
$ helm3 2to3
Migrate Helm v2 configuration and releases in-place to Helm v3
Usage:
2to3 [command]
Available Commands:
convert migrate Helm v2 release in-place to Helm v3
help Help about any command
move migrate Helm v2 configuration in-place to Helm v3
Flags:
-h, --help help for 2to3
Use "2to3 [command] --help" for more information about a command.
现在插件支持的功能主要有两个部分:
- 迁移 Helm V2 配置
- 迁移 Helm V2 release
开始迁移
$ helm3 2to3 move config
[Helm 2] Home directory: /Users/ych/.helm
[Helm 3] Config directory: /Users/ych/Library/Preferences/helm
[Helm 3] Data directory: /Users/ych/Library/helm
[Helm 3] Create config folder "/Users/ych/Library/Preferences/helm" .
[Helm 3] Config folder "/Users/ych/Library/Preferences/helm" created.
[Helm 2] repositories file "/Users/ych/.helm/repository/repositories.yaml" will copy to [Helm 3] config folder "/Users/ych/Library/Preferences/helm/repositories.yaml" .
[Helm 2] repositories file "/Users/ych/.helm/repository/repositories.yaml" copied successfully to [Helm 3] config folder "/Users/ych/Library/Preferences/helm/repositories.yaml" .
[Helm 3] Create data folder "/Users/ych/Library/helm" .
[Helm 3] data folder "/Users/ych/Library/helm" created.
[Helm 2] plugins "/Users/ych/.helm/plugins" will copy to [Helm 3] data folder "/Users/ych/Library/helm/plugins" .
[Helm 2] plugins "/Users/ych/.helm/plugins" copied successfully to [Helm 3] data folder "/Users/ych/Library/helm/plugins" .
[Helm 2] starters "/Users/ych/.helm/starters" will copy to [Helm 3] data folder "/Users/ych/Library/helm/starters" .
[Helm 2] starters "/Users/ych/.helm/starters" copied successfully to [Helm 3] data folder "/Users/ych/Library/helm/starters" .
上面的操作会迁移:
- Chart starters
- Chart 仓库
- 插件
确认是否安装成功
$ helm3 repo list
NAME URL
stable http://mirror.azure.cn/kubernetes/charts/
local http://127.0.0.1:8879/charts
$ helm3 plugin list
NAME VERSION DESCRIPTION
2to3 0.1.1 migrate Helm v2 configuration and releases in-place to Helm v3
push 0.7.1 Push chart package to ChartMuseum
非默认目录迁移
$ export HELM_V2_HOME=$HOME/.helm2
$ export HELM_V3_CONFIG=$HOME/.helm3
$ export HELM_V3_DATA=$PWD/.helm3
$ helm3 2to3 move config
迁移Helm V2 Release
命令详解
#命令详解:
$ helm3 2to3 convert -h
migrate Helm v2 release in-place to Helm v3
Usage:
2to3 convert [flags] RELEASE
Flags:
--delete-v2-releases v2 releases are deleted after migration. By default, the v2 releases are retained
--dry-run simulate a convert
-h, --help help for convert
-l, --label string label to select tiller resources by (default "OWNER=TILLER")
-s, --release-storage string v2 release storage type/object. It can be 'secrets' or 'configmaps'. This is only used with the 'tiller-out-cluster' flag (default "secrets")
-t, --tiller-ns string namespace of Tiller (default "kube-system")
--tiller-out-cluster when Tiller is not running in the cluster e.g. Tillerless
# 可以看到最后的 --tiller-out-cluster 参数,甚至支持 Tillerless Helm v2。
查看helm list
$ helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
minio 1 Wed Sep 11 11:47:51 2019 DEPLOYED minio-2.5.13 RELEASE.2019-08-07T01-59-21Z argo
redis 1 Wed Sep 11 14:52:57 2019 DEPLOYED redis-9.1.7 5.0.5 redis
测试
$ helm3 2to3 convert --dry-run minio
NOTE: This is in dry-run mode, the following actions will not be executed.
Run without --dry-run to take the actions described below:
Release "minio" will be converted from Helm 2 to Helm 3.
[Helm 3] Release "minio" will be created.
[Helm 3] ReleaseVersion "minio.v1" will be created.
迁移
确认没有问题了,我们再执行迁移.
我们可以查看上面的dry-run模式下面的一些描述信息,没有什么问题的话就可以真正的来执行迁移操作了:
# 开始迁移
$ helm3 2to3 convert minio
Release "minio" will be converted from Helm 2 to Helm 3.
[Helm 3] Release "minio" will be created.
[Helm 3] ReleaseVersion "minio.v1" will be created.
[Helm 3] ReleaseVersion "minio.v1" created.
[Helm 3] Release "minio" created.
Release "minio" was converted successfully from Helm 2 to Helm 3. Note: the v2 releases still remain and should be removed to avoid conflicts with the migrated v3 releases.
# 迁移完成后的
$ helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
minio 1 Wed Sep 11 11:47:51 2019 DEPLOYED minio-2.5.13 RELEASE.2019-08-07T01-59-21Z argo
redis 1 Wed Sep 11 14:52:57 2019 DEPLOYED redis-9.1.7 5.0.5 redis
$ helm3 list
NAME NAMESPACE REVISION UPDATED STATUS CHART
# 需要指定名称空间才能看到
$ helm3 list -n argo
NAME NAMESPACE REVISION UPDATED STATUS CHART
minio argo 1 2019-09-11 03:47:51.239461137 +0000 UTC deployed minio-2.5.13
注意
注意:由于我们没有指定–delete-v2-releases选项,所以 Helm V2 minio 这个 release 信息还是存在的,我们可以在以后使用 kubectl 进行删除。
当你准备好迁移你所有的 releases 的时候,你可以循环helm list里面的所有 release 来自动的将每个 Helm V2 release 迁移到 Helm V3 版本去。
如果你正在使用 Tillerless Helm V2,只需要指定–tiller-out-cluster选项来迁移 release 即可:
$ helm3 2to3 convert minio --tiller-out-cluster
清理helm2的数据
- 删除主文件夹~/.helm
- 如果你没有使用–delete-v2-releases选项,那么旧使用 kubectl 工具来删除 Tiller releases 数据
- 卸载掉烦人的 Tiller