5
1

More than 3 years have passed since last update.

Azure Kubernetes ServiceでHelm2→Helm3にアップデートする

Last updated at Posted at 2020-11-30

セゾン情報システムズ Advent Calendar 2020 がスタートしました!
1日目を担当します。よろしくお願いします。

初日からだいぶマニアックですが気にせずいきます。
Azure Kubernetes ServiceでHelm2→Helm3へバージョンアップしたのでその手順を書き残したいと思います。

Helmとは

公式ページ から引用します。

Helm は、Kubernetes アプリケーションの管理を支援します。
Helm チャートは、最も複雑な Kubernetes アプリケーションの定義、インストール、およびアップグレードを支援します。

簡単に書くとKubernetes向けのyumやaptのようなパッケージマネージャーということですね。

Helm v2 EOL

ある日以下のようなメールが送られてきました。

Upgrade from using Helm 2 to Helm 3 for your AKS cluster(s) 
You're receiving this email because you have Azure Kubernetes Services (AKS) cluster(s) running Tiller, which is installed as part of Helm 2. 

Azure Kubernetes ServiceでHelm2を使ってアプリケーションをインストールしているユーザーは連絡がきているはずです。
Helm2がサポートされなくなるためHelm3へのアップデートを推奨する連絡ですね。

Helm v2 Deprecation Timeline

Helm v2 → v3

環境

  • クライアントPC:Windows 10
  • Kubernetes:Azure Kubernetes Service v16

事前状態確認

  • AKSの状態を事前に取得しておきます。
# kubectl get ns
# kubectl get all -n kube-system
# kubectl get all -n [NameSpace]
  • Helm v3の最新版をダウンロードします。今回はWindows版をダウンロードしました。

  • ダウンロードしたhelm.exeをhelm3.exeにリネームします。こうすることで、以降helmコマンドはhelm2、helm3コマンドはhelm3で実行されます。

  • helm2のバージョンを確認しておきます。

# helm version
Client: &version.Version{SemVer:"v2.14.0", GitCommit:"xxx", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.0", GitCommit:"xxx", GitTreeState:"clean"}
  • helm3のバージョンを確認します。先ほどダウンロードしてリネームしたhelm3を実行しています。
# helm3 version
version.BuildInfo{Version:"v3.4.0", GitCommit:"xxx", GitTreeState:"clean", GoVersion:"go1.14.10"}
  • 現状helm2インストール済みリソース一覧を表示しておきます。
# helm list
NAME            REVISION        UPDATED                         STATUS          CHART                   APP VERSION     NAMESPACE
cert-manager    2                                               DEPLOYED        cert-manager-vx.x.x     vx.x.x          cert-manager
  • helm3インストール済みリソースを表示します。現時点では何も管理されていません。
# helm3 list
NAME    NAMESPACE       REVISION        UPDATED STATUS  CHART   APP VERSION
  • helm2リポジトリ一覧を表示しておきます。
# helm repo list
NAME            URL
stable          https://kubernetes-charts.storage.googleapis.com
local           http://127.0.0.1:8879/charts
jetstack        https://charts.jetstack.io
  • helm3リポジトリ一覧を表示します。現時点では何も管理されていません。
# helm3 repo list
Error: no repositories to show

移行

  • helm2to3プラグインをインストールします。ここはPowerShellだと実行時にエラーになったのでgit bashで実行しています。
# ./helm3.exe plugin install https://github.com/helm/helm-2to3
  • helm3プラグインリストを確認します。2to3がインストールされていればOKです。
# helm3 plugin list
NAME    VERSION DESCRIPTION
2to3    0.7.0   migrate and cleanup Helm v2 configuration and releases in-place to Helm v3
  • 2to3プラグインの実行を確認します。
# 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.
  • helm2のコンフィグを移行します。まずはdry-runオプションを付与してシミュレーションします。
# helm3 2to3 move config --dry-run
NOTE: This is in dry-run mode, the following actions will not be executed.
Run without --dry-run to take the actions described below:
WARNING: Helm v3 configuration may be overwritten during this operation.
[Move config/confirm] Are you sure you want to move the v2 configuration? [y/N]: y
Helm v2 configuration will be moved to Helm v3 configuration.
中略
  • helm2のコンフィグを移行します。
# helm3 2to3 move config
WARNING: Helm v3 configuration may be overwritten during this operation.
[Move config/confirm] Are you sure you want to move the v2 configuration? [y/N]: y
Helm v2 configuration will be moved to Helm v3 configuration.
~ 中略 ~
Helm v2 configuration was moved successfully to Helm v3 configuration.
  • helm3リポジトリ一覧を表示します。今回は一覧が表示されています。現時点ではWARNINGは無視します。
# helm3 repo list
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
NAME            URL
stable          https://kubernetes-charts.storage.googleapis.com
local           http://127.0.0.1:8879/charts
jetstack        https://charts.jetstack.io
  • Helm v2リリースを移行します。まずはdry-runオプションを付与してシミュレーションします。複数ある場合は繰り返し実行します。
# helm3 2to3 convert --dry-run [Release Name]
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
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 "xxxx-xxxx" will be converted from Helm v2 to Helm v3.
[Helm 3] Release "xxxx-xxxx" will be created.
[Helm 3] ReleaseVersion "xxxx-xxxx.v1" will be created.
  • Helm v2リリースを移行します。複数ある場合は繰り返し実行します。
# helm3 2to3 convert [Release Name]
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
Release "xxxx-xxxx" will be converted from Helm v2 to Helm v3.
[Helm 3] Release "xxxx-xxxx" will be created.
[Helm 3] ReleaseVersion "xxxx-xxxx.v1" will be created.
[Helm 3] ReleaseVersion "xxxx-xxxx.v1" created.
[Helm 3] Release "xxxx-xxxx" created.
Release "xxxx-xxxx" was converted successfully from Helm v2 to Helm v3.
Note: The v2 release information still remains and should be removed to avoid conflicts with the migrated v3 release.
v2 release information should only be removed using `helm 2to3` cleanup and when all releases have been migrated over.
  • helm3リポジトリ一覧を表示します。
# helm3 list --all-namespaces
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
xxxx-xxxx       namespace       1                                                       deployed        nginx-ingress-x.x.x     x.x.x 

事後状態確認

  • AKSの状態を取得します。
# kubectl get ns
# kubectl get all -n kube-system
# kubectl get all -n [NameSpace]

古いデータ削除

  • cleanupコマンドを使って古いデータを削除します。実行後はkube-systemにあるtillerが削除されます。まずはdry-runオプションを付与してシミュレーションします。
# helm3 2to3 cleanup --dry-run
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
NOTE: This is in dry-run mode, the following actions will not be executed.
Run without --dry-run to take the actions described below:
WARNING: "Helm v2 Configuration" "Release Data" "Tiller" 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
Helm v2 data will be cleaned up.
~中略~
  • cleanupコマンドを使って古いデータを削除します。
# helm3 2to3 cleanup
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
WARNING: "Helm v2 Configuration" "Release Data" "Tiller" 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
Helm v2 data will be cleaned up.
~中略~
Helm v2 data was cleaned up successfully.
  • deployment.apps/tiller-deployが削除されていることを確認します。
# kubectl get all -n kube-system

事後作業

  • helm3.exeをhelmにリネームします。これで今後helmコマンド実行時はhelm3で実行されます。

  • stableリポジトリを最新化します。

# helm repo add stable https://charts.helm.sh/stable --force-update
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable"
"stable" has been added to your repositories
# helm repo list
NAME            URL
stable          https://charts.helm.sh/stable
local           http://127.0.0.1:8879/charts
jetstack        https://charts.jetstack.io
  • Helmリポジトリをアップデートしておきます。
# helm repo update
Update Complete. ?Happy Helming!?
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1