Friday, November 15, 2024
Google search engine
HomeGuest BlogsHow to Roll Back Changes with Helm

How to Roll Back Changes with Helm

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 HelmHow 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 commandFinding 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 commandFinding 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 commandRolling 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 commandRoll 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 commandRoll 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

RELATED ARTICLES

Most Popular

Recent Comments