skip to content

In a Helm Chart.yaml dependency, what does the condition field do, and what happens if its values path is absent?

level: juniorimportance: must knowfreq 62%

answer

  1. A per-dependency on/off switch
  2. Declared beside name and version
  3. Points at a dotted values path
  4. Must resolve to a real boolean
  5. Missing path means no opinion

basics

~20 s

condition names a dotted values path, such as database.enabled, on a Chart.yaml dependency entry. If that path resolves to a boolean, it decides whether Helm renders that subchart at all. If the path is absent, the condition is ignored and the dependency stays enabled.

solid answer

~50 s

In `Chart.yaml`, each entry under `dependencies` may carry a `condition`: one values path, or a comma-separated list of paths, that switches the subchart on or off. Before rendering, Helm evaluates the paths against the values the release is being rendered with. The first path that resolves to a **boolean** decides; a path that does not exist is skipped silently; a value that is not a boolean is ignored with a warning. If nothing resolves, the dependency keeps its default state, which is enabled. Disabled means the subchart's templates produce nothing at all - no objects in the manifest, no hooks. It does not mean the dependency is gone: it is still declared, still pinned in `Chart.lock`, still vendored under `charts/` and still shipped inside the packaged `.tgz`. So a caller turns a bundled component off with `--set db.enabled=false` or a values file, without forking the chart.

code

yaml · 11 lines
yaml
apiVersion: v2
name: billing
version: 4.2.1
dependencies:
  - name: postgresql
    version: 15.3.2
    repository: https://charts.example.internal
    condition: postgresql.enabled
  - name: billing-lib
    version: 2.9.0
    repository: https://charts.example.internal

go deeper

for a junior

Be ready to say where the field lives - a dependency entry in Chart.yaml - and to name the flag that turns a bundled component off at install time without editing the chart.

for a middle

Explain the resolution order: comma-separated paths tried left to right, first boolean wins, missing paths skipped, non-booleans warned about and ignored, default enabled.

for a senior

Show that you verify rather than trust. A misspelled path fails silently, so demonstrate rendering with the real values first and reading what the chart actually produced.

for a principal

Own the authoring convention: which switches a shared chart exposes, what their defaults are, and why one conditioned chart beats a forked copy per environment across a fleet of services.

### Where the field lives A chart declares what it bundles in `Chart.yaml`, under `dependencies`. Each entry has a `name`, a `version` range and a `repository`, and may add `alias`, `tags`, `import-values` and `condition`. `condition` is the on/off switch for that one dependency: ```yaml apiVersion: v2 name: billing version: 4.2.1 dependencies: - name: postgresql version: 15.3.2 repository: https://charts.example.internal condition: postgresql.enabled ``` The string is a **values path**, written with dots, addressed from the top of the values tree the release is rendered with. It is not a template expression - there is no `{{ }}`, no function, no comparison. It can only point at something that is already a boolean. ### How Helm resolves it Before any template is executed, Helm walks the dependency list and computes an `enabled` flag for every entry. Everything starts enabled. For an entry with a condition, Helm splits the string on commas and tries each path in order: - the first path that resolves to a boolean wins, and evaluation stops there; - a path that does not exist in the values is skipped, and the next path is tried; - a path that exists but holds something else - the *string* `"false"`, a number, a map - is not usable, and Helm logs a warning and moves on; - if no path yields a boolean, the condition contributes nothing and the dependency keeps whatever state it already had. Two consequences bite people. First, resolution is **silent on failure**: a typo such as `postgresql.enable` is simply a path that does not exist, so the subchart renders and no error is printed. Second, YAML types matter: `postgresql.enabled: "false"` is a quoted string, not a boolean, and it will not disable anything. `--set postgresql.enabled=false` produces a real boolean; `--set-string` would not. The comma-separated form exists so a chart can honour more than one switch, for example a specific key and a shared fallback: `condition: postgresql.enabled,global.bundledDatabase`. The first of those that actually exists in the caller's values decides, so a specific per-chart key overrides a broad one only because it is listed first. ### What "disabled" actually means A disabled dependency is **not rendered**. None of its templates execute, so none of its objects appear in the manifest Helm applies and stores with the revision, and none of its hook manifests exist to be run. Its `NOTES.txt` contributes nothing. From the cluster's point of view the subchart may as well not be in the chart. What does *not* change is packaging. The entry is still in `Chart.yaml`, still pinned in `Chart.lock`, still vendored as a `.tgz` under `charts/`, and still inside the parent's packaged archive. Enablement is a render-time decision taken from values; it is not a way to slim down a chart or to avoid fetching a dependency. ### Why charts are built this way The pattern exists so one chart can serve two shapes of deployment. A team ships a chart for a subscription-billing service that bundles a database subchart so a developer can `helm install` it on a laptop and get something that works. In production the same chart runs against a managed database, and the platform team passes `postgresql.enabled=false` plus an external host in a values file. There is one chart, one version stream, and no fork - the difference between the environments is data, reviewed in a values file, not a divergent copy of the templates. Chart authors therefore give the switch a default in the parent's own `values.yaml` (usually `enabled: true`, so the out-of-the-box install works) and document the key. Consumers flip it per environment. ### Checking it Because the failure mode is silence, verify rather than assume. Rendering locally with the exact values you intend to use shows precisely which objects the chart will produce, and grepping that output for the subchart's resources answers the question directly - before anything reaches a cluster.

  • A condition reads postgresql.enabled,global.bundledDatabase. How is that pair resolved?
    Helm tries the paths left to right and takes the first one that exists and holds a boolean, then stops. If `postgresql.enabled` is set anywhere in the release's values it decides, and `global.bundledDatabase` is never consulted. If only the second is set, it decides. If neither exists, the condition contributes nothing and the dependency stays enabled.
  • Does disabling a dependency stop helm dependency update from fetching it?
    No. Dependency resolution and vendoring happen from `Chart.yaml` alone, with no values in play, so the subchart is still downloaded into `charts/`, still pinned in `Chart.lock`, and still packaged inside the parent's `.tgz`. The condition is evaluated later, at render time, and only decides whether the vendored chart's templates execute.
  • Why does --set db.enabled="false" fail to disable a subchart?
    Quoting makes it the string `"false"`, and a condition only acts on a genuine boolean. Helm finds the path, sees a non-boolean, logs a warning and leaves the dependency enabled. Use `--set db.enabled=false`, or write `enabled: false` unquoted in a values file; never route it through `--set-string`.

A condition is the wiring for a light switch the installer leaves on the wall: the fixture ships with the house either way, and whoever moves in decides whether it draws power.

saying these in an interview costs you the question

  • Thinking a missing condition path disables the dependency
  • Writing condition as a template expression with curly braces
  • Expecting an error when the condition path is misspelled
  • Believing a disabled subchart is dropped from charts/ or the .tgz
  • Passing the quoted string "false" and expecting it to switch off
  • Assuming a disabled subchart's hooks still run

context