X

How to migrate helm v2 to helm v3


This article will guide you about how to migrate helm v2 to helm v3 along with currently running resources in the environment.


In my previous article we have seen how to install helm version 2. Now in this article we are going to migrate currently running helm v2 configuration and its running resources to helm v3. To perform migration of helm v2 to helm v3 we are going to install plugin called 2to3 in the helm3.

Steps to migrate helm v2 to helm v3:

  • Check currently running resources in helm v2
# helm ls
NAME    REVISION        UPDATED                         STATUS          CHART           APP VERSION     NAMESPACE
mynginx 1               Tue Jun 30 02:22:13 2020        DEPLOYED        nginx-6.0.1     1.19.0          default
# kubectl get all
NAME                           READY   STATUS    RESTARTS   AGE
pod/mynginx-5bd8cb6d45-k5vlx   1/1     Running   0          54s

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
service/kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP                      28d
service/mynginx      NodePort    10.103.194.212   <none>        80:30672/TCP,443:30500/TCP   54s

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/mynginx   1/1     1            1           54s

NAME                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/mynginx-5bd8cb6d45   1         1         1       54s
  • Download helm v3 binaries and unzip it.

Please note that helm v3 dont have tiller component running within kubernetes cluster.

# wget https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
--2020-06-30 02:24:33--  https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
Resolving get.helm.sh (get.helm.sh)... 152.199.39.108, 2606:2800:247:1cb7:261b:1f9c:2074:3c
Connecting to get.helm.sh (get.helm.sh)|152.199.39.108|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12926032 (12M) [application/x-tar]
Saving to: ‘helm-v3.2.4-linux-amd64.tar.gz.1’

helm-v3.2.4-linux-amd64.tar.gz.1  100%[============================================================>]  12.33M  2.73MB/s    in 4.4s

2020-06-30 02:24:39 (2.77 MB/s) - ‘helm-v3.2.4-linux-amd64.tar.gz.1’ saved [12926032/12926032]
# tar -zxvf helm-v3.2.4-linux-amd64.tar.gz
linux-amd64/
linux-amd64/helm
linux-amd64/README.md
linux-amd64/LICENSE

Now once we unzipped the file change directory to “linux-amd64”. You will find helm binary. Now we are going to copy this binary as helm3 at the location /usr/local/bin in order to differentiate between helm v2 and helm v3 binary.

# cd linux-amd64
# mv helm /usr/local/bin/helm3

Check the version details of the helm v3 binary.

# helm3 version
version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"
# helm3 version --short
v3.2.4+g0ad800e

just cross check whether we have currently manage chart in helm v2 and helm v3 version using helm list command as  below:

# helm3 list
NAME    NAMESPACE       REVISION        UPDATED STATUS  CHART   APP VERSION
# helm list
NAME    REVISION        UPDATED                         STATUS          CHART           APP VERSION     NAMESPACE
mynginx 1               Tue Jun 30 02:22:13 2020        DEPLOYED        nginx-6.0.1     1.19.0          default

As you can see that helm v3 is not managing any chart however we do have one chart deployed in helm v2 named mynginx which we are going to migrate to helm v3.

  • Install plugin 2to3 in helm v3 environemnt using below command.
# helm3 plugin install https://github.com/helm/helm-2to3
Downloading and installing helm-2to3 v0.5.1 ...
https://github.com/helm/helm-2to3/releases/download/v0.5.1/helm-2to3_0.5.1_linux_amd64.tar.gz
Installed plugin: 2to3
# helm3 plugin list
NAME    VERSION DESCRIPTION
2to3    0.5.1   migrate and cleanup Helm v2 configuration and releases in-place to Helm v3

To check all the options in 2to3 plugin use help option  as below:

# helm3 2to3 help
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.

As you can see that, there is move command which will migrate helm v2 to helm v3. So lets do config migration to v3.

  • Perform the dry-run of the migration to check which resources or config is going to migrate to helm v3 version using command below:
# helm3 2to3 move config --dry-run
2020/06/30 02:32:35 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/06/30 02:32:35 Run without --dry-run to take the actions described below:
2020/06/30 02:32:35
2020/06/30 02:32:35 WARNING: Helm v3 configuration may be overwritten during this operation.
2020/06/30 02:32:35
[Move Config/confirm] Are you sure you want to move the v2 configuration? [y/N]: y
2020/06/30 02:32:44
Helm v2 configuration will be moved to Helm v3 configuration.
2020/06/30 02:32:44 [Helm 2] Home directory: /root/.helm
2020/06/30 02:32:44 [Helm 3] Config directory: /root/.config/helm
2020/06/30 02:32:44 [Helm 3] Data directory: /root/.local/share/helm
2020/06/30 02:32:44 [Helm 3] Cache directory: /root/.cache/helm
2020/06/30 02:32:44 [Helm 3] Create config folder "/root/.config/helm" .
2020/06/30 02:32:44 [Helm 2] repositories file "/root/.helm/repository/repositories.yaml" will copy to [Helm 3] config folder "/root/onfig/helm/repositories.yaml" .
2020/06/30 02:32:44 [Helm 3] Create cache folder "/root/.cache/helm" .
2020/06/30 02:32:44 [Helm 3] Create data folder "/root/.local/share/helm" .
2020/06/30 02:32:44 [Helm 2] starters "/root/.helm/starters" will copy to [Helm 3] data folder "/root/.local/share/helm/starters" .

As in the above output it has given all the details about migration lets perform the actual migration below command without –dry-run option.

# helm3 2to3 move config
2020/06/30 02:32:56 WARNING: Helm v3 configuration may be overwritten during this operation.
2020/06/30 02:32:56
[Move Config/confirm] Are you sure you want to move the v2 configuration? [y/N]: y
2020/06/30 02:32:57
Helm v2 configuration will be moved to Helm v3 configuration.
2020/06/30 02:32:57 [Helm 2] Home directory: /root/.helm
2020/06/30 02:32:57 [Helm 3] Config directory: /root/.config/helm
2020/06/30 02:32:57 [Helm 3] Data directory: /root/.local/share/helm
2020/06/30 02:32:57 [Helm 3] Cache directory: /root/.cache/helm
2020/06/30 02:32:57 [Helm 3] Create config folder "/root/.config/helm" .
2020/06/30 02:32:57 [Helm 3] Config folder "/root/.config/helm" created.
2020/06/30 02:32:57 [Helm 2] repositories file "/root/.helm/repository/repositories.yaml" will copy to [Helm 3] config folder "/root/onfig/helm/repositories.yaml" .
2020/06/30 02:32:57 [Helm 2] repositories file "/root/.helm/repository/repositories.yaml" copied successfully to [Helm 3] config fold "/root/.config/helm/repositories.yaml" .
2020/06/30 02:32:57 [Helm 3] Create cache folder "/root/.cache/helm" .
2020/06/30 02:32:57 [Helm 3] cache folder "/root/.cache/helm" created.
2020/06/30 02:32:57 [Helm 3] Create data folder "/root/.local/share/helm" .
2020/06/30 02:32:57 [Helm 3] data folder "/root/.local/share/helm" created.
2020/06/30 02:32:57 [Helm 2] starters "/root/.helm/starters" will copy to [Helm 3] data folder "/root/.local/share/helm/starters" .
2020/06/30 02:32:57 [Helm 2] starters "/root/.helm/starters" copied successfully to [Helm 3] data folder "/root/.local/share/helm/staers" .
2020/06/30 02:32:57 Helm v2 configuration was moved successfully to Helm v3 configuration.

The above command only migrates the helm v2 to helm v3. In case you want to migrate currently deployed charts from helm v2 to helm v3 you need to use convert command:

Check currently deployed charts in helm v2 using below command:

# helm list
NAME    REVISION        UPDATED                         STATUS          CHART           APP VERSION     NAMESPACE
mynginx 1               Tue Jun 30 02:22:13 2020        DEPLOYED        nginx-6.0.1     1.19.0          default
  • Migrate the deployed charts

For the first we are going to perform dry-run.

# helm3 2to3 convert mynginx --dry-run
2020/06/30 02:33:59 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/06/30 02:33:59 Run without --dry-run to take the actions described below:
2020/06/30 02:33:59
2020/06/30 02:33:59 Release "mynginx" will be converted from Helm v2 to Helm v3.
2020/06/30 02:33:59 [Helm 3] Release "mynginx" will be created.
2020/06/30 02:33:59 [Helm 3] ReleaseVersion "mynginx.v1" will be created.

We are ok with above output as its not given any error or issues while converting the deployed chart to helm v3. Now lets move the deployed resource to helm v3 without –dry-run option.

# helm3 2to3 convert mynginx
2020/06/30 02:34:22 Release "mynginx" will be converted from Helm v2 to Helm v3.
2020/06/30 02:34:22 [Helm 3] Release "mynginx" will be created.
2020/06/30 02:34:22 [Helm 3] ReleaseVersion "mynginx.v1" will be created.
2020/06/30 02:34:23 [Helm 3] ReleaseVersion "mynginx.v1" created.
2020/06/30 02:34:23 [Helm 3] Release "mynginx" created.
2020/06/30 02:34:23 Release "mynginx" was converted successfully from Helm v2 to Helm v3.
2020/06/30 02:34:23 Note: The v2 release information still remains and should be removed to avoid conflicts with the migrated v3 relee.
2020/06/30 02:34:23 v2 release information should only be removed using `helm 2to3` cleanup and when all releases have been migrated er.

To confirm migration lets use helm3 list output and also we will check pods, deployments in kubernetes using kubectl.

# helm3 list
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mynginx default         1               2020-06-30 06:22:13.361117663 +0000 UTC deployed        nginx-6.0.1     1.19.0

----------------------------------------------------------------------------------------------------------------------------------------------
# kubectl get all -o wide
NAME                           READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES
pod/mynginx-5bd8cb6d45-k5vlx   1/1     Running   0          12m   10.244.1.85   kworker01   <none>           <none>

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE   SELECTOR
service/kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP                      28d   <none>
service/mynginx      NodePort    10.103.194.212   <none>        80:30672/TCP,443:30500/TCP   12m   app.kubernetes.io/instance=mynginxpp.kubernetes.io/name=nginx

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                                        SELECTOR
deployment.apps/mynginx   1/1     1            1           12m   nginx        docker.io/bitnami/nginx:1.19.0-debian-10-r2   app.kubertes.io/instance=mynginx,app.kubernetes.io/name=nginx

NAME                                 DESIRED   CURRENT   READY   AGE   CONTAINERS   IMAGES                                        SELTOR
replicaset.apps/mynginx-5bd8cb6d45   1         1         1       12m   nginx        docker.io/bitnami/nginx:1.19.0-debian-10-r2   appubernetes.io/instance=mynginx,app.kubernetes.io/name=nginx,pod-template-hash=5bd8cb6d45

The above output confirms that we have successfully migrated deployed charts to helm v3. Now lets remove helm v2 binaries and tiller component and move back helm3 bianary to helm as a final step.

# helm3 2to3 cleanup
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 releas.
Helm v2 may not be usable afterwards.

[Cleanup/confirm] Are you sure you want to cleanup Helm v2 data? [y/N]: y
2020/06/30 02:35:40
Helm v2 data will be cleaned up.
2020/06/30 02:35:40 [Helm 2] Releases will be deleted.
2020/06/30 02:35:40 [Helm 2] ReleaseVersion "mynginx.v1" will be deleted.
2020/06/30 02:35:41 [Helm 2] ReleaseVersion "mynginx.v1" deleted.
2020/06/30 02:35:41 [Helm 2] Releases deleted.
2020/06/30 02:35:41 [Helm 2] Tiller in "kube-system" namespace will be removed.
2020/06/30 02:35:41 [Helm 2] Tiller "deploy" in "kube-system" namespace will be removed.
2020/06/30 02:35:41 [Helm 2] Tiller "deploy" in "kube-system" namespace was removed successfully.
2020/06/30 02:35:41 [Helm 2] Tiller "service" in "kube-system" namespace will be removed.
2020/06/30 02:35:43 [Helm 2] Tiller "service" in "kube-system" namespace was removed successfully.
2020/06/30 02:35:43 [Helm 2] Tiller in "kube-system" namespace was removed.
2020/06/30 02:35:43 [Helm 2] Home folder "/root/.helm" will be deleted.
2020/06/30 02:35:43 [Helm 2] Home folder "/root/.helm" deleted.
2020/06/30 02:35:43 Helm v2 data was cleaned up successfully.
# helm list
Error: could not find tiller

So clean up done successfully also tiller component also terminated which was part of helm v2.

Now remove the helm v2 binary and move helm v3 binary as helm.

# rm -rf /usr/local/bin/helm
# mv /usr/local/bin/helm3 /usr/local/bin/helm
# helm list
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mynginx default         1               2020-06-30 06:22:13.361117663 +0000 UTC deployed        nginx-6.0.1     1.19.0
# helm version --short
v3.2.4+g0ad800e

So in this way we can perform migration of helm v2 to helm v3.

 

Related Post