Skip to main content
Version 3.0

Go back to the previous revision
without losing data.

Roll back the update of a component when something goes wrong: through the Helm release history, or through Git when the component is an Argo CD Application. Also see what to protect first, because not every schema migration has a way back.

CompatibilityKubernetes1.32+OpenShift4.19+Rancher2.10.x+Helm3.2.0+

Rollback returns a component to the previous revision: in Helm, by choosing a revision from the release history. In Argo CD, by reverting in Git the commit that changed the version, because the cluster follows the repository. In both cases, the volume snapshot comes first.

Your environment

If you fill in your environment details here, examples and commands on the page use what you entered. REVISION is the revision number from helm history that you want to return to.

Before any rollback

Back up the persistent data. Depending on the component, a rollback can cause data loss if the schema migrations of the new version are incompatible with the previous one. Scenario 1 shows how to create the volume snapshot.

Scenarios​

Identify the component PVCs and create a snapshot of each one before rolling back.

An update went wrong and you are going to roll back. Before touching the release or Git, the component volumes need a snapshot: if the new version has already migrated the database schema, the previous version may not be able to read what was left, and the snapshot is the only way back for the data.

Via Helm

The release keeps the revision history. The rollback chooses one of them: scenario 2.

Via Argo CD

The cluster follows Git. The rollback is reverting the update commit and synchronizing: scenario 3.

The data snapshot and where the history lives

How was the component installed?

Your choice changes the commands and passages below.

1st2nd3rdVolumeSnapshotbefore anything elseRelease historyhelm historyhelm rollbacknew revisionComponentprevious version
  1. PVC snapshot. A rollback can lose data if the schema migrations of the new version are not compatible with the previous one. The snapshot guarantees the way back. (kubectl apply -f - <<EOF … kind: VolumeSnapshot … EOF)
  2. Release revisions. Each install or upgrade creates a revision. The rollback returns the release to one of them, without needing the old chart or values. (helm history <RELEASE_NAME> -n <NAMESPACE>)
  3. Rollback. Creates a new revision with the content of the chosen revision. Without a number, it returns to the immediately previous one. (helm rollback <RELEASE_NAME> <REVISION> -n <NAMESPACE>)
  4. Verification. The last history entry is deployed, with the description Rollback to <REVISION>. (helm status <RELEASE_NAME> -n <NAMESPACE>)

How was the component installed?: Via Helm

1st2nd3rdVolumeSnapshotbefore anything elseRelease historyhelm historyhelm rollbacknew revisionComponentprevious version
  1. PVC snapshot. A rollback can lose data if the schema migrations of the new version are not compatible with the previous one. The snapshot guarantees the way back. (kubectl apply -f - <<EOF … kind: VolumeSnapshot … EOF)
  2. Release revisions. Each install or upgrade creates a revision. The rollback returns the release to one of them, without needing the old chart or values. (helm history <RELEASE_NAME> -n <NAMESPACE>)
  3. Rollback. Creates a new revision with the content of the chosen revision. Without a number, it returns to the immediately previous one. (helm rollback <RELEASE_NAME> <REVISION> -n <NAMESPACE>)
  4. Verification. The last history entry is deployed, with the description Rollback to <REVISION>. (helm status <RELEASE_NAME> -n <NAMESPACE>)

How was the component installed?: Via Argo CD

1st2nd3rdVolumeSnapshotbefore anything elseGit historyupdate commitArgo CDautomated + selfHealComponentprevious version
  1. PVC snapshot. A rollback can lose data if the schema migrations of the new version are not compatible with the previous one. The snapshot guarantees the way back. (kubectl apply -f - <<EOF … kind: VolumeSnapshot … EOF)
  2. git revert. The commit that changed the version is reverted in the repository. The cluster follows Git: nothing is changed directly in it. (git revert <COMMIT_HASH> && git push origin main)
  3. Synchronization. The kit Applications synchronize on their own when they detect the revert. With automated sync turned off, run argocd app sync. (argocd app sync <APPLICATION_NAME>)
  4. Verification. The Application returns to Synced and Healthy. (argocd app get <APPLICATION_NAME>)
Switch above. The snapshot is the same on both paths. What changes is where the history is kept.

Identify the component PVCs

The list of volumes that the rollback can affect.

Terminal input
kubectl get pvc -n <NAMESPACE> -l app.kubernetes.io/instance=<RELEASE_NAME>

Create a snapshot of each volume

A consistent copy of each PVC, when the StorageClass supports snapshots.

Terminal input
kubectl get volumesnapshotclass

kubectl apply -f - <<EOF
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: <RELEASE_NAME>-pre-rollback-snapshot
namespace: <NAMESPACE>
spec:
volumeSnapshotClassName: <SNAPSHOT_CLASS>
source:
persistentVolumeClaimName: <PVC_NAME>
EOF

Repeat for each PVC listed in the previous step, changing name and persistentVolumeClaimName.

Confirm the snapshot is ready

No rollback until all snapshots are usable.

Terminal input
kubectl get volumesnapshot -n <NAMESPACE>

It worked when

Each snapshot shows READYTOUSE equal to true. Only then move on to scenario 2 or 3.
If the cluster has no VolumeSnapshotClass

The StorageClass does not support snapshots.

Best practices​

  • Keep Git consistent with the cluster state: on an installation via Argo CD, always revert through Git. Argo CD synchronizes the cluster with the repository.

Next steps​