← Recipes

阅读中文版本

Verify Helm Values Override Precedence

Render charts with multiple values files to confirm the final merged values match the intended precedence before release.

~20 minhelmkubernetesops

Task

Render Helm templates with layered values and diff the effective configuration.

When to use this

A production override silently shadows a base setting, and the release ships with an unexpected replica count.

Prerequisites

  • Helm 3
  • Base and environment values files
  • A chart to render

Steps

1. Render with all values files in the real order.

helm template app ./chart \
  -f values.yaml -f values.staging.yaml \
  --set image.tag=1.2.3 > rendered.yaml

Expected output: The rendered manifest reflects the last file and --set winning.

2. Confirm the effective value of a critical key.

helm template app ./chart -f values.yaml -f values.staging.yaml \
  --show-only templates/deployment.yaml | grep -A2 -i replicas

Expected output: The replica count matches the highest-precedence source, verifying precedence.

Troubleshooting

Problem

--set always wins unexpectedly

Solution

Know that later files and --set override earlier files; reorder or move shared defaults to the base file.

Problem

Lists are replaced not merged

Solution

Helm replaces arrays; duplicate the full list in the override to avoid surprises.

Limitations

  • helm template does not test cluster admission.
  • Precedence is positional and easy to misread.
  • Does not cover secrets templating errors.

What this recipe does

Render Helm templates with layered values and diff the effective configuration.

A production override silently shadows a base setting, and the release ships with an unexpected replica count.

Prerequisites

  • Helm 3
  • Base and environment values files
  • A chart to render

Procedure

  1. Render with all values files in the real order.
helm template app ./chart \
  -f values.yaml -f values.staging.yaml \
  --set image.tag=1.2.3 > rendered.yaml

Expected result: The rendered manifest reflects the last file and –set winning.

  1. Confirm the effective value of a critical key.
helm template app ./chart -f values.yaml -f values.staging.yaml \
  --show-only templates/deployment.yaml | grep -A2 -i replicas

Expected result: The replica count matches the highest-precedence source, verifying precedence.

How to confirm it worked

Run the commands above and confirm every expected result in order. If a step does not produce the stated output, use the troubleshooting notes before continuing. A passing run shows the rendered manifest shows values from the intended layer and CI stores the rendering for review.

Troubleshooting

–set always wins unexpectedly — Know that later files and –set override earlier files; reorder or move shared defaults to the base file.

Lists are replaced not merged — Helm replaces arrays; duplicate the full list in the override to avoid surprises.

Limitations

  • helm template does not test cluster admission.
  • Precedence is positional and easy to misread.
  • Does not cover secrets templating errors.