How to Use Helm Upgrade for Kubernetes Deployments
Use
helm upgrade to update an existing Helm release with new chart versions or configuration changes. The command applies changes without uninstalling the release, keeping your app running smoothly.Syntax
The helm upgrade command updates a release with a new chart or configuration. It requires the release name and the chart path or name. Optional flags control behavior like installing if missing or setting values.
RELEASE: Name of the Helm release to upgrade.CHART: Path or name of the chart to use for upgrade.--install: Installs the release if it does not exist.--valuesor-f: Specify YAML files with configuration values.--set: Override values directly in the command line.
bash
helm upgrade [RELEASE] [CHART] [flags] # Example flags: # --install # install if release missing # -f values.yaml # use values file # --set key=value # override values
Example
This example upgrades a release named myapp using a local chart directory ./mychart. It sets a new image tag using --set and applies a values file.
bash
helm upgrade myapp ./mychart --install -f custom-values.yaml --set image.tag=v2.0.1
Output
Release "myapp" has been upgraded. Happy Helming!
NAME: myapp
LAST DEPLOYED: Fri Apr 26 15:00:00 2024
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
Common Pitfalls
Common mistakes when using helm upgrade include:
- Not using
--installwhen the release does not exist, causing upgrade to fail. - Forgetting to update the chart version or path, so no changes apply.
- Incorrect YAML syntax in values files causing upgrade errors.
- Overriding values incorrectly with
--set, leading to unexpected configurations.
Always check the release status after upgrade with helm status [RELEASE].
bash
## Wrong: upgrade fails if release missing helm upgrade myapp ./mychart ## Right: install if missing helm upgrade myapp ./mychart --install
Quick Reference
| Flag | Description |
|---|---|
| --install | Install release if it does not exist |
| -f, --values | Specify values YAML file |
| --set | Set or override values on the command line |
| --namespace | Specify Kubernetes namespace |
| --timeout | Time to wait for upgrade to complete |
Key Takeaways
Use
helm upgrade to update releases without downtime.Add
--install to create the release if missing.Use
-f or --set to customize configuration during upgrade.Check upgrade success with
helm status [RELEASE].Avoid YAML syntax errors in values files to prevent upgrade failures.