Sub topic 5
Installing, upgrading, and rolling back releases
This chapter assumes you have the webapp chart from the earlier chapters, Helm 3 installed, a kubectl context that points at a test cluster, and a working knowledge of values overrides.
What a release is
A release is one named installation of a chart in a namespace. You can install the same chart several times under different names, and each installation is tracked separately. Helm 3 has no server component. Each revision of a release is stored as a Secret in the release's namespace, named like sh.helm.release.v1.my-release.v2. That Secret holds the rendered manifest and the values used. This is what makes history and rollback possible.
Installing
Render and check the install first, then run it for real:
helm install my-release ./webapp --namespace demo --create-namespace --dry-run --debug
helm install my-release ./webapp --namespace demo --create-namespace --set replicaCount=3
helm list -n demo
helm status my-release -n demohelm list shows each release with its revision number and status. helm status prints the status of one release, along with any notes the chart provides.
Upgrading
An upgrade renders the chart again with new values or a new chart version, then applies the difference to the cluster. Each upgrade creates a new revision.
helm upgrade --install my-release ./webapp -n demo --set image.tag=1.27.1--install makes the command work whether or not the release exists yet. That makes it a good fit for CI pipelines.
Values behave in a way that surprises many people. By default, helm upgrade starts from the chart's own defaults and applies only the overrides on the current command line. An earlier --set replicaCount=3 is dropped unless you repeat it. There are two ways to avoid this:
- Keep all overrides in a values file and pass it with
-fon every install and upgrade. - Pass
--reuse-valuesto start from the previous revision's values. It can hide new chart defaults, so prefer the values file.
For safer rollouts, add --wait, --timeout 5m, and --atomic. --wait makes Helm block until resources are ready. --atomic also rolls the release back automatically if the upgrade fails.
helm upgrade my-release ./webapp -n demo -f values-prod.yaml --atomic --timeout 5mHistory and rollback
Use helm history to see every revision, then helm rollback to return to one.
helm history my-release -n demo
helm rollback my-release 1 -n demoA rollback does not rewind the history. It creates a new revision, here revision 3, whose manifest matches revision 1. The history stays linear, so you can always see what happened.
Uninstalling
helm uninstall my-release -n demoThis deletes the resources the release created and its history. Use --keep-history to keep the revision records. The release then shows as uninstalled, and you can inspect or roll back to it. Helm does not delete the namespace, even if you created it with --create-namespace.
Common errors
| Message | Cause | Fix |
|---|---|---|
| `cannot re-use a name that is still in use` | A release with that name already exists in the namespace | Use `helm upgrade --install`, or choose another name |
| `another operation (install/upgrade/rollback) is in progress` | An earlier command was interrupted and left the release in a pending state | Check `helm history`, then roll back to the last good revision |
| `has no deployed releases` | The first install failed, so no good revision exists | Run `helm uninstall`, fix the cause, and install again |
| `invalid ownership metadata` | An object with the same name was created outside Helm | Delete or adopt the object, then retry |
Exercise
You ran helm install my-release ./webapp --set replicaCount=3. Later you run helm upgrade my-release ./webapp --set image.tag=1.27.1. How many replicas does revision 2 have, and why? Then you run helm rollback my-release 1. What revision number is created?
Show answer
Revision 2 uses the chart default of 2 replicas. By default, an upgrade does not carry over earlier --set values, so replicaCount=3 is lost. Pass the value again, use a values file, or add --reuse-values. The rollback creates revision 3, whose content matches revision 1.