• This repository has been archived on 17/Jul/2024
  • Stars
    star
    494
  • Rank 89,130 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚠️(OBSOLETE) This is a Helm v3 plugin which migrates and cleans up Helm v2 configuration and releases in-place to Helm v3

Helm 2to3 Plugin

License Go Report Card CircleCI Release

diagram

Helm v3 plugin which migrates and cleans up Helm v2 configuration and releases in-place to Helm v3

Overview

One of the most important aspects of upgrading to a new major release of Helm is the migration of data. This is especially true of Helm v2 to v3 considering the architectural changes between the releases. The 2to3 plugin helps with this migration by supporting:

Readme before migration

WARNING: All data migrations carry a level of risk. Helm v2 migration is no different. You should be aware of any risks specific to your environment and prepare a data migration strategy for your needs.

Here are some suggestions to mitigate against potential risks during migration:

  • Perform a data backup of the following:
    • Helm v2 home folder.
    • Release data from the cluster. Refer to How Helm Uses ConfigMaps to Store Data for details on how Helm v2 store release data in the cluster. This should apply similarly if Helm v2 is configured for secrets.
  • Avoid performing operations with Helm v3 until data migration is complete and you are satisfied that it is working as expected. Otherwise, Helm v3 data might be overwritten. The operations to avoid are chart install, adding repositories, plugin install etc.
  • The recommended data migration path is as follows:
    1. Backup v2 data, as suggested above.
    2. Migrate Helm v2 configuration.
    3. Migrate Helm v2 releases.
    4. When happy that Helm v3 is managing Helm v2 data as expected, then clean up Helm v2 data. Note:: Only use the plugin to do clean up. Using helm, kubectl or other tools could lead to data loss and an indeterminate state for the release(s).

Note: A Helm v2 client:

  • can manage 1 to many Kubernetes clusters.
  • can connect to 1 to many Tiller instances for a cluster.

This means that you have to cognisant of this when migrating as releases are deployed into clusters by Tiller and its namespace. You have to therefore be aware of migrating for each cluster and each Tiller instance that is managed by the Helm v2 client instance. Clean up should only be run once all migration for a Helm v2 client is complete.

Prerequisite

  • Helm v2 client installed on a system which manages releases on one to many clusters
  • Helm v3 client with 2to3 plugin installed on the same system
  • Access to the cluster(s) that Helm v2 client is managing and which Helm v3 will manage after migration. This access is similar to kubectl access using kubeconfig files. The --kubeconfig and --kube-context flags can be used with the convert and cleanup commands to set the kubeconfig path and context to override the environment configuration.
  • Access to the tiller namespace for required RBAC roles. If Tillerless setup, then a service account with the proper cluster wide RBAC roles will need to be used. If not used, forbidden errors will be thrown when trying to access restricted resources.
    • The plugin requires these RBAC resource permissions at the least. Additional resources might be needed depending on your environment setup
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRole
      metadata:
        name: <your-helm-cluster-role-name>
      rules:
      - apiGroups:
          - ""
        resources:
          - pods
        verbs:
          - list
          - get
      - apiGroups:
          - ""
        resources:
          - configmaps
        verbs:
          - list
          - get
          - delete

Recommended Prior to Migration

This is a list of recommendations prior to migration:

Install

Based on the version in plugin.yaml, release binary will be downloaded from GitHub:

$ helm plugin install https://github.com/helm/helm-2to3.git
Downloading and installing helm-2to3 v0.1.3 ...
https://github.com/helm/helm-2to3/releases/download/v0.1.3/helm-2to3_0.1.3_darwin_amd64.tar.gz
Installed plugin: 2to3

For Windows (using WSL)

Helm's plugin install hook system relies on /bin/sh, regardless of the operating system present. Windows users can work around this by using Helm under WSL.

$ wget https://get.helm.sh/helm-v3.0.0-linux-amd64.tar.gz
$ tar xzf helm-v3.0.0-linux-amd64.tar.gz
$ ./linux-amd64/helm plugin install https://github.com/helm/helm-2to3

Usage

Migrate Helm v2 configuration

Migrate Helm v2 configuration in-place to Helm v3:

$ helm 2to3 move config [flags]

Flags:

      --dry-run  simulate a command
      --skip-confirmation   if set, skips confirmation message before performing move
  -h, --help     help for move

It will migrate:

  • Chart starters
  • Repositories
  • Plugins

Note:

  • The move config command will create the Helm v3 config and data folders if they don't exist, and will override the repositories.yaml file if it does exist.
  • For migration it uses default Helm v2 home and v3 config and data folders. To override those folders you need to set environment variables HELM_V2_HOME, HELM_V3_CONFIG and HELM_V3_DATA:
$ export HELM_V2_HOME=$PWD/.helm2
$ export HELM_V3_CONFIG=$PWD/.helm3
$ export HELM_V3_DATA=$PWD/.helm3
$ helm 2to3 move config

Readme after configuration migration

  • After running the command, check that all Helm v2 plugins work fine with the Helm v3. If any issue with a plugin, remove it (<helm3> plugin remove) and re-add (<helm3> plugin install) it as required.
  • The repository file repositories.yaml is copied to Helm v3 which contains references to repositories added in Helm v2. Local respoitories are not copied to Helm v3. You should remove all local repositories from Helm v3 using <helm3> repo remove and re-add where necessary using <helm3> repo add. This is a necessary refresh to align references for Helm v3.
  • When you are happy with your repository list, update the Helm v3 repo <helm3> repo update. This cleans up any Helm v2 cache references from Helm v3.

Migrate Helm v2 releases

Migrate Helm v2 releases in-place to Helm v3

$ helm 2to3 convert [flags] RELEASE

Flags:

      --delete-v2-releases         v2 release versions are deleted after migration. By default, the v2 release versions are retained
      --dry-run                    simulate a command
  -h, --help                       help for convert
      --ignore-already-migrated    Ignore any already migrated release versions and continue migrating
      --kube-context string        name of the kubeconfig context to use
      --kubeconfig string          path to the kubeconfig file
  -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")
      --release-versions-max int   limit the maximum number of versions converted per release. Use 0 for no limit (default 10)
  -t, --tiller-ns string           namespace of Tiller (default "kube-system")
      --tiller-out-cluster         when  Tiller is not running in the cluster e.g. Tillerless

Note: There is a limit set on the number of versions/revisions of a release that are converted. It is defaulted to 10 but can be configured with the --release-versions-max flag. When the limit set is less that the actual number of versions then only the latest release versions up to the limit will be converted. Older release versions with not be converted. If --delete-v2-releases is set, these older versions will remain in Helm v2 storage but will no longer be visible to Helm v2 commands like helm list. Clean up will remove them from storage.

Clean up Helm v2 data

Clean up Helm v2 configuration, release data and Tiller deployment:

$ helm 2to3 cleanup [flags]

Flags:

      --config-cleanup           if set, configuration cleanup performed
      --dry-run                  simulate a command
  -h, --help                     help for cleanup
      --kube-context string      name of the kubeconfig context to use
      --kubeconfig string        path to the kubeconfig file
  -l, --label string             label to select Tiller resources by (default "OWNER=TILLER")
      --name string              the release name. When it is specified, the named release and its versions will be removed only. Should not be used with other cleanup operations
      --release-cleanup          if set, release data cleanup performed
  -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")
      --skip-confirmation        if set, skips confirmation message before performing cleanup
      --tiller-cleanup           if set, Tiller cleanup performed
  -t, --tiller-ns string         namespace of Tiller (default "kube-system")
      --tiller-out-cluster       when  Tiller is not running in the cluster e.g. Tillerless

A full clean will remove the:

  • Configuration (Helm home directory)
  • v2 release data
  • Tiller deployment

Note: Before performing a full or release data clean, remove any Helm v2 releases which have not been migrated to Helm v3 and are unwanted. They can be removed using the Helm v2 delete command. If they are not removed before clean up of the v2 release data then the Kubernetes resources deployed by the Helm release will remain in your cluster. In other words, the resources will be 'orphaned' without any Helm release associated.

Cleanup of individual parts can be performed using the following flags:

  • --config-cleanup for configuration
  • --release-cleanup for v2 release data
  • --tiller-cleanup for Tiller deployment
  • --name for a release and its versions. This is a singular operation and is not to be used with the other cleanup operations.

If none of these flags are set, then full cleanup is performed.

The cleanup uses the default Helm v2 home folder. To override this folder you need to set the environment variable HELM_V2_HOME:

$ export HELM_V2_HOME=$PWD/.helm2
$ helm 2to3 cleanup

Warning: The full cleanup command will remove the Helm v2 Configuration, Release Data and Tiller Deployment. It cleans 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 will not be usable afterwards. Full cleanup should only be run once all migration (clusters and Tiller instances) for a Helm v2 client instance is complete. Helm v2 may also become unusable depending on cleanup of individual parts.

Troubleshooting

Q. I get an error when I try to do a chart dependency update in Helm v3 after configuration migration

Error might be similar to the following:

$ helm dep update chrt-1/
Hang tight while we grab the latest from your chart repositories...
...Unable to get an update from the "local" chart repository (http://127.0.0.1:8879/charts):
Get http://127.0.0.1:8879/charts/index.yaml: dial tcp 127.0.0.1:8879: connect: connection refused
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈Happy Helming!⎈
Error: open /home/usr1/.cache/helm/repository/local-index.yaml: no such file or directory

A. Local respoitories are not copied to Helm v3. You therefore need to remove all local repositories from Helm v3 using <helm3> repo remove and re-add where required using <helm3> repo add. This is a necessary refresh to align references for Helm v3 and remove the conflict. It is worthwhile to also refresh the repository list afterwards: <helm3> repo update. You should then be able to run the chart dependency update command successfully.

Q. I get an error when I try to do a helm upgrade in Helm v3 after migration

Error might be similar to the following:

$ helm upgrade nginx bitnami/nginx
Error: failed to download "bitnami/nginx" (hint: running `helm repo update` may help)

A. This can happen when there are conflicts in the local repository list that Helm v3 cannot resolve. This can be fixed by running the helm repo update command.

Frequently Asked Questions

Q. How do you perform Helm v2 release migration as a batch operation?

A. You can perform batch migration of releases using a command as follows:

$ kubectl get [configmap|secret] -n <tiller_namespace> \
 -l "OWNER=TILLER" | awk '{print $1}' | grep -v NAME | cut -d '.' -f1 | uniq | xargs -n1 helm 2to3 convert

An example of migrating releases which are stored as ConfigMaps in Tiller namespace kube-system:

$ kubectl get configmap -n kube-system -l "OWNER=TILLER" \
 | awk '{print $1}' | grep -v NAME | cut -d '.' -f1 | uniq | xargs -n1 helm 2to3 convert

Developer (From Source) Install

If you would like to handle the build yourself, this is the recommended way to do it.

You must first have Go v1.18 installed, and then you run:

$ git clone [email protected]:helm/helm-2to3.git
$ cd helm-2to3
$ make build
$ export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true
$ helm plugin install <your_path>/helm-2to3

That last command will use the binary that you built.

More Repositories

1

helm

The Kubernetes Package Manager
Go
26,750
star
2

charts

⚠️(OBSOLETE) Curated applications for Kubernetes
Go
15,492
star
3

chartmuseum

helm chart repository server
Go
3,484
star
4

monocular

⚠️(OBSOLETE) Search and discovery UI for Helm Chart repositories
Go
1,421
star
5

chart-testing

CLI tool for linting and testing Helm charts
Go
1,355
star
6

helm-mapkubeapis

This is a Helm plugin which map deprecated or removed Kubernetes APIs in a release to supported APIs
Go
857
star
7

chart-releaser

Hosting Helm Charts via GitHub Pages and Releases
Go
652
star
8

helm-classic

⚠️(OBSOLETE) Helm Classic v1
Go
575
star
9

chart-releaser-action

A GitHub Action to turn a GitHub project into a self-hosted Helm chart repo, using helm/chart-releaser CLI tool
Shell
530
star
10

community

Helm community content
413
star
11

kind-action

A GitHub Action for Kubernetes IN Docker - local clusters for testing Kubernetes
Shell
274
star
12

hub

⚠️(OBSOLETE) Former distributed charts search for hub.helm.sh. Now see https://artifacthub.io/
250
star
13

chart-testing-action

A GitHub Action to lint and test Helm charts
Shell
226
star
14

helm-www

The Helm website for docs, blog and project info.
SCSS
195
star
15

charts-classic

⚠️(OBSOLETE) Charts for Helm Classic v1
Shell
140
star
16

charts-repo-actions-demo

Example project to demo testing and hosting a chart repository with GitHub Pages and Actions
Mustache
104
star
17

examples

Helm chart repository for example charts
Smarty
59
star
18

helm-summit-notes

Helm Summit notes from February 2018
25
star
19

acceptance-testing

Acceptance test suite for the Helm client
Shell
24
star
20

prow

⚠️(OBSOLETE) Developer utilities for Helm
20
star
21

rudder-federation

⚠️(OBSOLETE) Federation support as a Tiller plugin
Go
18
star
22

charts-tooling

Tooling to support github.com/helm/charts
Go
10
star
23

pull-sizer

Label pull requests based on the size of their changes
Go
8
star
24

docker-kubectl-helm-az

⚠️(OBSOLETE) Azure CLI Dockerfile with kubectl and Helm
Dockerfile
8
star
25

rudder-appcontroller

⚠️(OBSOLETE) The AppController backend for Tiller
Go
7
star
26

docker-kubectl-helm-aws

⚠️(OBSOLETE) AWS CLI Dockerfile with kubectl and Helm
Dockerfile
7
star
27

get-helm-sh

Azure ARM templates to deploy https://get.helm.sh
5
star
28

homebrew-tap

Homebrew Formulas for Helm Tools
Ruby
5
star
29

specs

Specifications for Helm interfaces including charts and repositories
5
star
30

query-store-quay-logs

Go
4
star
31

repo-audit

Repo Auditing tool - pre-alpha status
Go
4
star
32

github-webhook-dco-labeler

Utility application used by Helm charts to add a label to pulls when DCO passes
Go
4
star
33

charts-check-pr-title

Go
3
star
34

get-helm

⚠️(OBSOLETE) Install script for Helm Classic v1
Shell
2
star