Sub topic 5
Rendering and debugging with helm template, lint and --dry-run
This chapter assumes you have Helm 3 installed, can read Kubernetes Deployment YAML, and have scaffolded or written a small chart like the webapp chart from earlier chapters. You will learn three commands that show you what a chart produces before it touches a cluster.
The working model
Helm renders templates on your machine. The result is plain YAML that the Kubernetes API receives. Most chart bugs appear at one of three points: the template fails to parse, the template renders but produces invalid YAML, or the YAML is valid but Kubernetes rejects it. Each command below checks an earlier or later point.
The three commands
helm lint ./webapp
helm template my-release ./webapp --set replicaCount=3
helm install my-release ./webapp --dry-run --debug| Command | Needs a cluster | What it shows |
|---|---|---|
| `helm lint` | No | Chart structure problems, template syntax errors, schema failures |
| `helm template` | No | The rendered manifests only |
| `helm install --dry-run --debug` | Yes | Computed values, rendered manifests, and the server's response |
helm lint
helm lint ./webapp checks that Chart.yaml is valid, that templates parse, and that values satisfy values.schema.json if one exists. It reports [INFO], [WARNING] and [ERROR] lines. Only errors make the command fail. Run it first because it is fast.
helm template
helm template renders every file in templates/ and prints the YAML. It never contacts a cluster. The release name is the first argument, and it fills .Release.Name. Use --set or -f to test overrides, and --show-only templates/deployment.yaml to print one file.
Because no cluster is involved, .Capabilities uses default values. A chart that branches on .Capabilities.APIVersions may render differently here than on a real cluster.
helm install --dry-run --debug
This runs the full install path, including a server-side check, but does not create resources. --debug adds the computed values. Use it to catch errors that only the API server can find, such as an unknown field or a bad apiVersion.
Reading common errors
nil pointer evaluating interface {}.repository: a template reads.Values.image.repository, butimageis missing from the values. Add the key or guard it withwithorrequired.error converting YAML to JSON: mapping values are not allowed: the template rendered, but the output is not valid YAML. This is usually an indentation or whitespace mistake. Usehelm templateto see the exact output.function "xyz" not defined: a misspelled function name.unknown fieldfrom the server: the YAML is valid but the manifest is wrong. Only the dry run reports this.
When helm template itself fails and shows nothing, run it with --debug. Helm then prints the partly rendered output along with the error, so you can see where it stopped.
A debugging workflow
- Run
helm lintafter every edit. - Run
helm templateand read the output for the file you changed. - Use
--show-onlyto narrow the output. - Run
helm install --dry-run --debugbefore a real install. - To inspect a value mid-template, temporarily print it with
{{ .Values | toYaml }}inside a comment line, then remove it.
Exercise
You changed templates/deployment.yaml and want to see only its rendered output, with replicaCount set to 5, without needing a cluster. Which command do you run?
Show answer
helm template my-release ./webapp --set replicaCount=5 --show-only templates/deployment.yaml
Exercise
helm template succeeds, but helm install --dry-run --debug fails with "unknown field". At which stage does the problem occur, and why did helm template not catch it?
Show answer
The YAML is valid and renders correctly, but the Kubernetes API server rejects the manifest. helm template never contacts the server, so it cannot validate fields against the cluster's schema. Only the dry run, which includes a server-side check, reports the error.