Sub topic 1
Why Helm: charts, releases, and repositories
Prerequisites
This chapter assumes you already know:
- Basic Kubernetes objects: Pods, Deployments, Services, and ConfigMaps.
- How to read and write YAML.
- How to run
kubectlagainst a cluster. - Enough command-line skill to run shell commands and read their output.
You also need Helm 3 installed and a cluster that kubectl can reach. Helm uses the same kubeconfig file as kubectl.
The problem Helm solves
A real application is rarely one manifest. A web service might need a Deployment, a Service, a ConfigMap, an Ingress, and a ServiceAccount. Applying these with kubectl apply -f works for one environment. Problems start when you need more than that:
- Staging and production differ in replica count, image tag, and hostnames. Copying the YAML files leads to drift.
kubectl applyhas no concept of "this set of objects is one application." You cannot ask the cluster which version of the app is installed.- Undoing a bad change means finding the old YAML and applying it again.
- Sharing an application with another team means sending a folder of files and a README.
Helm is a package manager for Kubernetes. It groups manifests into a versioned package, lets you configure the package at install time, and records every install as a named unit that you can upgrade or roll back.
The three core concepts
Helm's vocabulary comes down to three terms.
| Term | What it is | Where it lives |
|---|---|---|
| Chart | A package: templated manifests, default configuration, and metadata | A directory or a `.tgz` archive |
| Release | One installed instance of a chart in a cluster, with a name and a revision history | The cluster |
| Repository | A server that hosts packaged charts and lets you search and download them | An HTTP index or an OCI registry |
A chart is a recipe, and a release is the dish you cooked from it. You can install the same chart several times under different release names, for example shop-staging and shop-prod. Each release has its own configuration and its own history. Helm stores that history in the cluster as Secrets in the release's namespace, so there is no separate Helm server to run.
A chart carries templates, not final manifests. At install time Helm combines the templates with configuration values, produces plain Kubernetes YAML, and sends it to the API server. The next chapters cover how the pieces inside a chart fit together.
A first session
You can use Helm before writing any chart. This session adds a public repository, searches it, installs a chart as a release, and lists the result.
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm search repo bitnami/nginx
helm install web bitnami/nginx --namespace demo --create-namespace
helm list --namespace demoThe commands do the following:
helm repo addsaves a name and URL for the repository on your machine.helm repo updatedownloads the repository's index, a list of available charts and versions.helm search repoqueries that local index.helm install web bitnami/nginxcreates a release namedwebfrom thenginxchart.helm listshows releases in the namespace, with their revision number and status.
After the install, kubectl get all -n demo shows ordinary Kubernetes objects. Helm adds labels and annotations that mark them as belonging to the web release. That ownership record is what allows helm upgrade, helm rollback, and helm uninstall to act on the whole set at once.
Repositories and registries
Helm distributes charts in two ways:
- A classic chart repository is a web server that hosts an
index.yamlfile and chart archives. You register it withhelm repo add. - An OCI registry is the same kind of registry that stores container images. You reference charts by an
oci://URL and do not usehelm repo add.
Both deliver the same artifact, a versioned chart archive. The chapter on packaging and publishing covers publishing to either.
When Helm is a good fit
Helm works well when you deploy the same application in several environments, install third-party software such as databases and ingress controllers, or need revision history and rollback. It adds a templating layer to debug, so for a single static manifest that never changes, plain kubectl apply or Kustomize may be simpler.
Exercise
You install the same chart twice in one namespace, using the release names blog-a and blog-b. How many charts and how many releases exist, and why can you not install a second release named blog-a in that namespace?
Show answer
There is one chart and two releases. A release is an installed instance of a chart, so one chart can back many releases. Release names must be unique within a namespace because Helm tracks each release's revision history under its name. A second blog-a would collide with the existing release, so Helm refuses the install.