Sub topic 16
Packaging, installing and upgrading a release
This chapter assumes you have a working chart (like the webapp chart from earlier chapters), Helm 3 installed, and access to a Kubernetes cluster through kubectl. It covers the last step: turning the chart directory into a package and managing a release over time.
Charts, packages and releases
A chart is a directory of files. A package is that directory compressed into a single .tgz archive. A release is one installed instance of a chart in a cluster. You can install the same chart many times under different release names, and each release tracks its own values and history.
Packaging a chart
Lint first, then package. If the chart has dependencies, helm package can fetch them with --dependency-update.
helm lint ./webapp
helm package ./webappThe command writes webapp-0.1.0.tgz to the current directory. The file name comes from name and version in Chart.yaml. Use --destination ./dist to choose another folder.
Two version fields matter here:
| Field | Meaning | Change it when |
|---|---|---|
| `version` | Version of the chart itself | Any template or default value changes |
| `appVersion` | Version of the application the chart deploys | You deploy a new application release |
Chart versions must follow semantic versioning, such as 0.2.0. Bump version each time you publish a changed package, because repositories treat a version as immutable.
Installing a release
You can install from a directory or from a package. Both produce the same result.
helm install my-release ./webapp -n staging --create-namespace
helm install my-release webapp-0.1.0.tgz -f prod-values.yamlUse -n to pick the namespace. Release names are unique within a namespace, so a second install with the same name fails. Check what happened with these commands:
helm list -n staging
helm status my-release -n staging
helm get values my-release -n staging
helm get manifest my-release -n staginghelm get values shows only the values you supplied. Add --all to include the chart defaults.
Upgrading a release
helm upgrade renders the chart again with new values or a new chart version and applies the difference. Each upgrade creates a new numbered revision.
helm upgrade --install my-release ./webapp -n staging -f prod-values.yaml--install makes the command install the release if it does not exist yet, so the same line works in a deployment script on the first and every later run. Add --atomic to roll back automatically if the upgrade fails, and --wait to wait until pods are ready.
Values are replaced, not merged
By default, an upgrade does not remember the values from the previous revision unless you pass them again. If you run helm upgrade my-release ./webapp --set replicaCount=5 and then a later upgrade without that flag, replicaCount returns to the chart default.
--reuse-valueskeeps the last revision's values and merges new--setflags on top. It can hide new defaults added in a newer chart version.- Passing the same
-ffile every time is the safer pattern, because the file in version control is the source of truth.
History, rollback and uninstall
Helm stores each revision as a Secret in the release namespace. You can inspect and return to an earlier one.
helm history my-release -n staging
helm rollback my-release 1 -n staging
helm uninstall my-release -n stagingA rollback does not rewind the history. It creates a new revision that reuses the manifest of the chosen one, so rolling back to revision 1 from revision 2 produces revision 3. Use --keep-history with uninstall if you want to keep the records.
Exercise
You run helm upgrade my-release ./webapp -f prod-values.yaml after earlier running helm upgrade my-release ./webapp --set replicaCount=5. What replica count do you get if prod-values.yaml does not set replicaCount, and which revision number does helm rollback my-release 1 create if the release is at revision 3?
Show answer
The chart default from values.yaml applies (2 in this tutorial's chart), because values from earlier upgrades are not reused unless you pass --reuse-values. The rollback creates revision 4, which uses the manifest from revision 1.