How to Roll Back Changes with Helm

February 3, 2021

Introduction

Helm is a package manager for Kubernetes that makes it easier to deploy applications and services, including rolling updates. Helm also lets you perform a rollback to a previous version of your application.

In this tutorial, we will cover different ways you can roll back changes using Helm.

How to roll back changes in Helm

Prerequisites

How to Roll Back to the Previous Release in Helm

Helm uses the rollback command to return to a previous revision:

1. Use the ls command to find the name of the current Helm release:

helm ls

In this case, the option -A lists releases across all namespaces:

Finding the release name with the helm ls command

2. Use the history command to find the current revision number:

helm history [release]
Finding the revision number with the helm history command

3. Roll back to a previous release by using the helm rollback command. The rollback command uses the following syntax:

helm rollback [release] [revision] [flag]

Where:

  • [release]: The release name you want to roll back to.
  • [revision]: The revision number you want to roll back to.
  • [flag]: Optional command flags, such as --dry-run or --force.

For example, to roll back to the WordPress release 1, revision 1, enter:

helm rollback wordpress-01 1
Rolling back to a previous release with the helm rollback command

Note: Omitting the revision number rolls the application back to the previous release. Learn how to get Helm values from old releases.

How to Roll Back Using kubectl

The rollout undo command allows you to roll back your deployment using kubectl:

kubectl rollout undo deployment/[release]
Roll back to a previous release using the kubectl command

To roll back to a specific revision, use:

kubectl rollout undo deployment/[release] --to-revision=[revision]
Roll back to a previous revision using the kubectl command

Note: Performing a rollback using kubectl will only roll back the deployment, without affecting other resources associated with the Helm release. Additionally, you can use kubectl to delete an unwanted copy of Helm deployment and namespace.

Conclusion

After following this tutorial, you should be able to roll back changes in Helm using the rollback command and kubectl.

Also, check out our guide to managing Helm repositories, or take a look at Kubernetes and all it can do.

Was this article helpful?
YesNo
Aleksandar Kovačević
With a background in both design and writing, Aleksandar Kovacevic aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
How to Add, Update or Remove Helm Repositories
December 21, 2020

Helm is Kubernetes' equivalent to apt and yum. It is a package manager used for deploying applications, which...
Read more
How to Install Helm on Ubuntu, Mac and Windows
October 30, 2024

Helm is a package manager for Kubernetes that simplifies deployment process. Follow this step-by-step...
Read more
19 Kubernetes Best Practices for Building Efficient Clusters
August 29, 2024

Kubernetes is a feature-rich orchestration tool. The best practices outlined in this article are going to...
Read more
How to Restart Kubernetes Pods
November 27, 2023

Kubernetes is one of the premier systems for managing containerized applications. But it isn't always able to...
Read more