Lesson 03 of 10 · How Helm works
Values at scale
Manage values for many environments and clusters without chaos: layer small files on top of chart defaults, validate everything with a JSON schema, keep secrets out of values, and preview every change before it reaches a cluster.
Layer small files
Most environments differ in only a few values: replicas, resources, hostnames, feature flags. Keep each difference in the smallest file:
charts/orders/values.yaml chart defaults (secure, sensible)
values/base.yaml organisation-wide settings for this service
values/prod.yaml production: replicas, resources, PDB
values/prod-eu.yaml region: hostname, data-residency flags
$ helm upgrade --install orders ./charts/orders -n shop \
-f values/base.yaml -f values/prod.yaml -f values/prod-eu.yaml
Precedence: chart defaults < each -f file in order < --set. Avoid --set in pipelines: it isn't in Git, so nobody can review it.
The school uniform list has a standard version, a short winter sheet that changes only the coat, and a PE sheet that changes only the shoes. Nobody rewrites the whole list for winter.
Validate with a schema
A values.schema.json next to Chart.yaml validates the merged values on install, upgrade, lint and template. Tested example:
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"required": [ "name", "image", "port" ],
"properties": {
"name": { "type": "string", "pattern": "^[a-z][a-z0-9-]{2,30}$" },
"image": { "type": "object", "required": [ "repository", "tag" ] },
"port": { "type": "integer", "minimum": 1, "maximum": 65535 },
"tier": { "type": "string", "enum": [ "tier-1", "tier-2", "tier-3" ] },
"replicas": { "type": "integer", "minimum": 1, "maximum": 20 }
}
}
$ helm template orders ./orders --set tier=gold
- tier: tier must be one of the following: "tier-1", "tier-2", "tier-3"
$ helm template orders ./orders --set name=Orders_1
- name: Does not match pattern '^[a-z][a-z0-9-]{2,30}$'
Global values and subcharts
Values under a subchart's name configure that subchart; global: values are visible to the parent and every subchart (useful for an image registry or a cluster domain). Use global for genuinely global settings only.
Keep secrets out
Values files live in Git and are stored in every release revision. Instead:
- reference an existing Secret by name (
existingSecret: orders-db), created by External Secrets or a secret-store CSI driver; - or keep values encrypted (SOPS with KMS/age) and decrypt at deploy time (helm-secrets, or your GitOps tool's decryption support).
Preview every change
helm diff upgrade(plugin) shows the exact object changes against the live release.- With GitOps, the pull request shows the values change and the GitOps tool shows the rendered diff before sync.
- Make the diff part of review for production changes.
Try it
Add the schema above to a chart, then try to install with a wrong type (--set replicas=three), a missing field and an unknown tier. Then create values/prod.yaml overriding only replicas and resources, render with and without it, and compare the output with diff.
Recap
- Layer small files over chart defaults; precedence is defaults <
-ffiles in order <--set. - Validate with
values.schema.json; useglobalsparingly. - Keep secrets out of values; preview every change with a diff.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.