Sub topic 1
Chart structure and Chart.yaml refresher
This chapter reviews what a Helm chart contains and which Chart.yaml fields matter before you add dependencies, hooks, and tests. Later chapters build on the layout described here.
Prerequisites
This chapter assumes you already know:
- Basic Kubernetes objects: Pods, Jobs, and Services.
- Helm 3 basics: install, upgrade, uninstall, and what a release is.
- Go template syntax as used in
templates/. - How to write and override a
values.yamlfile.
What a chart is
A chart is a directory of files that Helm packages and renders into Kubernetes manifests. Helm combines the templates with values and sends the result to the cluster as a release.
webapp/
Chart.yaml
values.yaml
charts/
templates/
_helpers.tpl
deployment.yaml
service.yaml
NOTES.txt
tests/
test-connection.yamlThe table shows what each path does and which later chapters use it.
| Path | Purpose | Used later for |
|---|---|---|
| `Chart.yaml` | Chart metadata and dependency declarations | Declaring dependencies |
| `values.yaml` | Default configuration values | Subchart and global values |
| `charts/` | Packaged or unpacked subcharts | Fetching dependencies |
| `templates/` | Go templates that render manifests | Hooks |
| `templates/tests/` | Templates for test Pods | Chart tests |
| `templates/_helpers.tpl` | Named templates, such as `webapp.fullname` | Naming hook and test resources |
Files in templates/ that start with an underscore are not rendered as manifests. Helm uses them only to define reusable named templates. NOTES.txt is rendered and printed after an install, but it is not applied to the cluster.
The next diagram shows how these parts become a release.
Reading Chart.yaml
Chart.yaml is the only required file besides templates/. This version is the starting point for the rest of the tutorial.
apiVersion: v2
name: webapp
description: Example web application chart
type: application
version: 0.1.0
appVersion: "1.0.0"The fields work as follows:
apiVersionisv2for charts that target Helm 3. Versionv1charts keep dependencies in a separaterequirements.yamlfile. Inv2thedependencieslist lives insideChart.yaml.nameis the chart name. By convention it matches the directory name, and Helm uses it as the package file name.descriptionis a one-line summary shown in search results.typeis eitherapplicationorlibrary. An application chart can be installed. A library chart only provides named templates for other charts to use, and Helm refuses to install it.versionis the version of the chart itself. It must be valid semantic versioning (SemVer), such as0.1.0. Change it whenever the chart's templates or defaults change.appVersionis the version of the application the chart deploys. It is informational and does not need to follow SemVer.
Version and appVersion are different
The two version fields change independently. If you fix a template bug without changing the application image, you raise version and leave appVersion alone. If you ship a new image with no template changes, you usually raise both, because the default image tag in values.yaml changed. Dependency constraints, covered in the next chapter, compare against a chart's version, not its appVersion.
Checking the structure
You can verify a chart's layout and metadata before any cluster is involved. These two commands are safe to run at any time:
helm lint ./webapp
helm template demo ./webapphelm lint reports malformed Chart.yaml fields, such as a version that is not SemVer, and common template problems. helm template renders the manifests locally and prints them, so you can confirm the layout produces what you expect. Both commands become part of the larger verification workflow later in this tutorial.
Common errors
- Directory name differs from
name. Lint warns when they do not match, and the packaged file name followsname, which causes confusion. - Non-SemVer
version. Values like1.0orv1fail validation. Use1.0.0. - Missing
apiVersion: v2. Helm treats the chart asv1, so adependencieslist inChart.yamlis not read the way you expect. - Editing files inside
charts/by hand. Helm manages that directory when you fetch dependencies, and manual edits are overwritten.
Exercise
A chart's Chart.yaml has version: 2.0 and appVersion: 3.1. Which field will helm lint complain about, and what should you change to avoid a surprise in how the other value is read?
Show answer
helm lint complains about version, because 2.0 is not valid SemVer. Change it to 2.0.0. Also quote appVersion as "3.1" so YAML keeps it as a string instead of reading it as a number. appVersion does not need to be SemVer, so lint does not reject it.
Exercise
You change only a template in templates/service.yaml and leave the application image alone. Which of version and appVersion should you raise?
Show answer
Raise version, because the chart itself changed. Leave appVersion alone, because the deployed application is the same.