Guest post originally published on Bitnami Docs by Vikram Vaswani

Introduction

Helm v3 was released a few months ago, bringing with a number of architectural changes and new features – most notably, the removal of Tiller and an improved upgrade process. To make it easier for users to transfer their Helm v2 releases to Helm v3, the Helm maintainers also released a plugin that takes care of migration tasks automatically.

After migrating your releases to Helm v3, you might come across some cases where subsequent upgrades fail – for example, when an upgrade attempts to modify an immutable field in a StatefulSet. In these situations, you can attempt to resolve the issue using one of the following methods:

This guide walks you through both these methods.

Assumptions and prerequisites

This guide makes the following assumptions:

helm2 repo add bitnami https://charts.bitnami.com/bitnami 
helm2 install --name postgres bitnami/postgresql \
  --set postgresqlPassword=PASSWORD \
  --set replication.password=REPL-PASSWORD \ 
  --set replication.slaveReplicas=1 \
  --set replication.enabled=true \
  --namespace default
helm3 plugin install https://github.com/helm/helm-2to3
helm3 2to3 move config
helm3 2to3 convert postgres

Tip For illustrative purposes, this guide demonstrates how to resolve post-migration upgrade issues using the Bitnami PostgreSQL Helm chart. However, the same approach can also be followed for other Bitnami Helm charts, subject to certain caveats explained in the following sections.

Throughout this guide, helm2 refers to the Helm v2 CLI and helm3 refers to the Helm v3 CLI.

Method 1: Backup and restore data using built-in application tools

This method involves using the application’s built-in backup/restore functionality to backup the data in the existing release and then restore this data in a new Helm v3 release. This method is only suitable for those applications which have built-in backup/restore functionality.

Step 1: Back up data using built-in PostgreSQL tools

The first step is to back up the data in the running PostgreSQL release. Follow these steps:

At the end of this step, you should have a backup file containing the data from your running PostgreSQL release.

Step 2: Restore the data into a new PostgreSQL release

The next step is to create an empty PostgreSQL cluster and restore the data into it:

Step 3: Test the upgrade process (optional)

You should now be able to upgrade to a new release. You can test this with the following command, replacing the VERSION placeholder with the chart version you wish to upgrade to:

helm3 upgrade --version VERSION postgres bitnami/postgresql \
  --namespace postgres-new \
  --set postgresqlPassword=PASSWORD \
  --set replication.password=REPL-PASSWORD \
  --set replication.slaveReplicas=1 \
  --set replication.enabled=true 

TipWhen upgrading the release, use the same parameters as when you installed it.

After confirming that all is in order, you can optionally delete your original release.

Method 2: Back up and restore persistent data volumes

This method involves copying the application’s persistent data volumes and reusing them in a new release. This method is only suitable for charts that allow using an existing persistent volume claim at install-time and on platforms supported by Velero. Many Bitnami Helm charts support this feature; review your specific chart’s available parameters for more information.

Step 1: Install Velero

Velero is an open source tool that makes it easy to backup and restore Kubernetes resources. It can be used to back up an entire cluster or, as shown below, it can be fine-tuned to only backup specific resources such as persistent volumes.

code example

Step 2: Back up the persistent data volumes

Next, back up the persistent volumes using Velero.

Step 3: Copy the persistent volumes to a new PostgreSQL release

You can now restore the persistent volumes and integrate them with a new Helm v3 release.

Step 4: Test the upgrade process (optional)

You should now be able to upgrade to a new release. You can test this with the following command, replacing the VERSION placeholder with the chart version you wish to upgrade to:

helm3 upgrade --version VERSION postgres bitnami/postgresql --set postgresqlPassword=hell0 --set replication.password=repl --set replication.slaveReplicas=1 --set replication.enabled=true --namespace postgres-new --set persistence.existingClaim=data-postgres-postgresql-master-0

TipWhen upgrading the release, use the same parameters as when you installed it.

After confirming that all is in order, you can optionally delete your original release.