Lesson 4 / 25

Values Files and Overrides

Override chart defaults with values files and --set, and predict which value wins.

Layers of configuration

Every chart ships a values.yaml with defaults. You override them when installing or upgrading, and Helm merges the layers in a fixed order, later layers winning: the chart's own values.yaml, then a parent chart's values for its subcharts, then each file passed with -f / --values in the order given, then --set, --set-string and --set-file flags. Maps are merged key by key, but lists are replaced entirely, not merged. --set uses a compact path syntax (image.tag=2.7.1, ingress.hosts[0].host=shop.example.com) that becomes awkward for anything complex, so keep real configuration in version-controlled values files and use --set mainly for values computed in a pipeline, such as an image tag. helm get values RELEASE shows the values you supplied; add --all to see the fully computed result.

Values precedence

Defaults sit at the bottom; each layer above overrides the ones below it.

Four stacked horizontal layers increasing in colour intensity from bottom to top, with an arrow pointing upward to show which wins.
Figure 2.1 — Chart defaults, values files in order, then --set flags.

Layered values for production

values-prod.yaml overrides values.yaml, and the pipeline sets only the image tag.

# values.yaml (chart defaults)
replicaCount: 1
image:
  repository: registry.example.com/shop-api
  tag: ""            # defaults to the chart's appVersion in templates
resources:
  requests: { cpu: 100m, memory: 128Mi }

# values-prod.yaml (environment overrides)
replicaCount: 3
resources:
  requests: { cpu: 500m, memory: 512Mi }
  limits:   { memory: 1Gi }

# command used by the pipeline
# helm upgrade --install shop-api ./charts/shop-api -n shop \
#   -f values-prod.yaml --set image.tag=2.7.1

Lists do not merge

If the defaults contain tolerations: [a, b] and your file sets tolerations: [c], the result is just [c]. Copy every list entry you want to keep into the override.

Quick check: A value is set in values.yaml, in values-prod.yaml passed with -f, and with --set. Which wins?

  • values.yaml
  • values-prod.yaml
  • The --set value
  • Whichever is alphabetically first
Answer

The --set value — --set overrides values files, which override the chart defaults.