How to Use Helm Rollback to Revert Kubernetes Releases
Use
helm rollback RELEASE_NAME REVISION to revert a Helm release to a previous revision. This command restores the release state to the specified revision, undoing recent changes.Syntax
The basic syntax of the helm rollback command is:
RELEASE_NAME: The name of the Helm release you want to revert.REVISION: The revision number to roll back to (usually a previous release version).- Optional flags like
--waitto wait for the rollback to complete.
bash
helm rollback RELEASE_NAME REVISION [flags]
Example
This example shows how to roll back a release named myapp to revision 2. It waits for the rollback to finish before returning.
bash
helm rollback myapp 2 --waitOutput
Rollback was a success! Happy Helming!\nNAME REVISION UPDATED STATUS CHART APP VERSION\nmyapp 3 2024-06-01 10:00:00 +0000 deployed mychart-1.0 1.0
Common Pitfalls
Common mistakes when using helm rollback include:
- Using the wrong revision number, which can roll back to an unintended state.
- Not waiting for the rollback to complete, causing confusion about the release status.
- Trying to roll back a release that has no previous revisions.
Always check the revision history with helm history RELEASE_NAME before rolling back.
bash
helm rollback myapp 5 # If revision 5 does not exist, you get an error: # Error: release: not found
Output
Error: release: not found
Quick Reference
| Command | Description |
|---|---|
| helm rollback RELEASE_NAME REVISION | Roll back to a specific revision |
| helm history RELEASE_NAME | Show revision history of a release |
| helm rollback RELEASE_NAME REVISION --wait | Roll back and wait for completion |
| helm rollback RELEASE_NAME REVISION --dry-run | Simulate rollback without applying changes |
Key Takeaways
Use helm rollback with the release name and revision number to revert changes.
Check revision history with helm history before rolling back.
Use --wait to ensure rollback completes before proceeding.
Avoid rolling back to non-existent revisions to prevent errors.
Rollback restores the release to a previous known good state safely.