はじめに
本記事では,helm3のリリースに伴い,helm2からhelm3へのマイグレーションを検証した記事になります.
マイグレーションのやり方については公式マイグレーション チュートリアルに掲載されているのですが,
この記事ではhelm2でDEPLOYED
以外の履歴もhelm3に受け継がれるのか気になったので試してみたいと思います.
※結論から言うと,
- helm3には
deleted
のみリスト表示するオプションが消えておりDELETED
などは受け継がれない - helm listで表示され方がnamespaceごとに変わった
ようでした.
環境
今回,検証にGKE使用を使用しました
- k8s cluster
- GKE
v1.13.11-gke.14
- GKE
またhelm2であらかじめ下記をデプロイしておきました
- helm2でデプロイされたもの
- cert-manager
- hackmd
- nginx-ingress(デプロイ後に削除済み)
- tiller(helm2のコンポーネント)
helm list -a
の結果はこんな感じ.
nginx-ingressが削除された履歴も残っています.
$ helm list -a
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
cert-manager 1 Thu Nov 21 13:50:37 2019 DEPLOYED cert-manager-v0.11.0 v0.11.0 cert-manager
hackmd 1 Thu Nov 21 13:44:16 2019 DEPLOYED hackmd-1.2.1 1.3.0-alpine default
nginx-ingress 1 Thu Nov 21 13:48:46 2019 DELETED nginx-ingress-1.24.4 0.26.1 default
helm3とマイグレ用プラグインの導入
wget https://get.helm.sh/helm-v3.0.0-darwin-amd64.tar.gz
tar xzf helm-v3.0.0-darwin-amd64.tar.gz
cd darwin-amd64/
mv helm helm3 # 説明上helmバージョンが分かりにくくなるので明示的にhelm3 とリネームしてます.
helm 2 to 3
というマイグレーション用プラグインが提供されているのでそちらを入れてみる
./helm3 plugin install https://github.com/helm/helm-2to3
入っているか確認.
./helm3 plugin list
NAME VERSION DESCRIPTION
2to3 0.2.0 migrate and cleanup Helm v2 configuration and releases in-place to Helm v3
このプラグインでは,
- 構成の移行
- リリースの移行
- 構成のクリーンアップ
- etc
ができるらしい.
./helm3 2to3
Migrate and Cleanup Helm v2 configuration and releases in-place to Helm v3
Usage:
2to3 [command]
Available Commands:
cleanup cleanup Helm v2 configuration, release data and Tiller deployment
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.
マイグレーション実行!
cert-manager, hackmd, nginx-ingress(削除済み)をそれぞれhelm3に移行していきます.
$ helm3 2to3 convert cert-manager
2019/12/08 14:44:35 Release "cert-manager" will be converted from Helm v2 to Helm v3.
2019/12/08 14:44:35 [Helm 3] Release "cert-manager" will be created.
2019/12/08 14:44:36 [Helm 3] ReleaseVersion "cert-manager.v1" will be created.
2019/12/08 14:44:37 [Helm 3] ReleaseVersion "cert-manager.v1" created.
2019/12/08 14:44:37 [Helm 3] Release "cert-manager" created.
2019/12/08 14:44:37 Release "cert-manager" was converted successfully from Helm v2 to Helm v3.
2019/12/08 14:44:37 Note: The v2 release information still remains and should be removed to avoid conflicts with the migrated v3 release.
2019/12/08 14:44:37 v2 release information should only be removed using `helm 2to3` cleanup and when all releases have been migrated over.
$ helm3 2to3 convert hackmd
2019/12/08 14:44:45 Release "hackmd" will be converted from Helm v2 to Helm v3.
2019/12/08 14:44:45 [Helm 3] Release "hackmd" will be created.
2019/12/08 14:44:45 [Helm 3] ReleaseVersion "hackmd.v1" will be created.
2019/12/08 14:44:47 [Helm 3] ReleaseVersion "hackmd.v1" created.
2019/12/08 14:44:47 [Helm 3] Release "hackmd" created.
2019/12/08 14:44:47 Release "hackmd" was converted successfully from Helm v2 to Helm v3.
2019/12/08 14:44:47 Note: The v2 release information still remains and should be removed to avoid conflicts with the migrated v3 release.
2019/12/08 14:44:47 v2 release information should only be removed using `helm 2to3` cleanup and when all releases have been migrated over.
$ helm3 2to3 convert nginx-ingress
2019/12/08 14:44:52 Release "nginx-ingress" will be converted from Helm v2 to Helm v3.
2019/12/08 14:44:52 [Helm 3] Release "nginx-ingress" will be created.
2019/12/08 14:44:53 [Helm 3] ReleaseVersion "nginx-ingress.v1" will be created.
2019/12/08 14:44:54 [Helm 3] ReleaseVersion "nginx-ingress.v1" created.
2019/12/08 14:44:54 [Helm 3] Release "nginx-ingress" created.
2019/12/08 14:44:54 Release "nginx-ingress" was converted successfully from Helm v2 to Helm v3.
2019/12/08 14:44:54 Note: The v2 release information still remains and should be removed to avoid conflicts with the migrated v3 release.
2019/12/08 14:44:54 v2 release information should only be removed using `helm 2to3` cleanup and when all releases have been migrated over.
エラーなくマイグレーション処理できたようです.
マイグレーション結果の確認
それでは,helm2でデプロイされたものがhelm3に引き継がれているかhelm list
確認しましょう.
$ helm3 list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hackmd default 1 2019-11-21 04:44:16.01041787 +0000 UTC deployed hackmd-1.2.1 1.3.0-alpine
あれ,cert-manager
nginx-ingress
が消えた!?
$ helm3 list --all-namespaces
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
cert-manager cert-manager 1 2019-11-21 04:50:37.881040911 +0000 UTC deployed cert-manager-v0.11.0 v0.11.0
hackmd default 1 2019-11-21 04:44:16.01041787 +0000 UTC deployed hackmd-1.2.1 1.3.0-alpine
どうやら, helm list
の挙動がデフォルトで全namespace表示だったところ, namespaceごとに表示範囲が変わったようです.
また,helm2で削除した履歴(nginx-ingress
)は残っていないようでした.
そもそも,helm3のlistコマンドにDELETEDのみを表示するオプションが消えていました.
$ helm3 list -h
~~~~~~~省略~~~~~~~~
Flags:
-a, --all show all releases, not just the ones marked deployed or failed
--all-namespaces list releases across all namespaces
-d, --date sort by release date
--deployed show deployed releases. If no other is specified, this will be automatically enabled
--failed show failed releases
~~~~~~~省略~~~~~~~~
clean up
最後にhelm2のリリース情報やhelm3から不要になったTiller
コンポーネントなどを削除して終わりたいと思います.
$ helm3 2to3 cleanup
WARNING: "Helm v2 Configuration" "Release Data" "Release Data" will be removed.
This will clean up all releases managed by Helm v2. It will not be possible to restore them if you haven't made a backup of the releases.
Helm v2 may not be usable afterwards.
[Cleanup/confirm] Are you sure you want to cleanup Helm v2 data? [y/N]: y
2019/12/08 14:59:47
Helm v2 data will be cleaned up.
2019/12/08 14:59:47 [Helm 2] Releases will be deleted.
2019/12/08 14:59:48 [Helm 2] ReleaseVersion "cert-manager.v1" will be deleted.
2019/12/08 14:59:49 [Helm 2] ReleaseVersion "cert-manager.v1" deleted.
2019/12/08 14:59:49 [Helm 2] ReleaseVersion "hackmd.v1" will be deleted.
2019/12/08 14:59:49 [Helm 2] ReleaseVersion "hackmd.v1" deleted.
2019/12/08 14:59:49 [Helm 2] ReleaseVersion "xrayed-rabbit.v1" will be deleted.
2019/12/08 14:59:49 [Helm 2] ReleaseVersion "xrayed-rabbit.v1" deleted.
2019/12/08 14:59:49 [Helm 2] Releases deleted.
2019/12/08 14:59:49 [Helm 2] Tiller in "kube-system" namespace will be removed.
2019/12/08 14:59:49 [Helm 2] Tiller "deploy" in "kube-system" namespace will be removed.
2019/12/08 14:59:52 [Helm 2] Tiller "deploy" in "kube-system" namespace was removed successfully.
2019/12/08 14:59:52 [Helm 2] Tiller "service" in "kube-system" namespace will be removed.
2019/12/08 14:59:53 [Helm 2] Tiller "service" in "kube-system" namespace was removed successfully.
2019/12/08 14:59:53 [Helm 2] Tiller in "kube-system" namespace was removed.
2019/12/08 14:59:53 [Helm 2] Home folder "/Users/kaz/.helm" will be deleted.
2019/12/08 14:59:53 [Helm 2] Home folder "/Users/kaz/.helm" deleted.
2019/12/08 14:59:53 Helm v2 data was cleaned up successfully.
%
以上の処理が完了すると(helm2での)helm list
やTiller
コンポーネントが消えたことが確認できました
helm list
Error: could not find tiller
おわりに
- helm3では
DELETED
のみリスト表示するオプションが無くなった - helm2 -> helm3移行で
DELETED
は引き継がれない -
helm list
で表示され方がnamespaceごとに変わった
deleteの履歴がマイグレーションで引き継がれないことによる弊害は考えにくいですが,
履歴が必要そうな人は気をつけたほうが良いかもしれませんね!