Working with .Values

The .Values object is how templates read configuration, whether from values.yaml or user overrides.

Syntax{{ .Values.parent.child }}

.Values is the single object your templates read for configuration. Whatever ends up in the merged values β€” from the chart default, override files, or --set β€” is reachable here.

Accessing nested keys

Use dots to descend into nested maps. For image.repository in values.yaml you write {{ .Values.image.repository }}.

Missing keys

Reading a key that does not exist yields an empty value rather than an error (unless you dig into a nil map). Combine with default or required to handle absence gracefully.

Example

Example Β· yaml
# Given values.yaml:
#   image:
#     repository: nginx
#     tag: "1.25"

containers:
  - name: web
    image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
    imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}

When to use it

  • A developer accesses .Values.image.tag in a Deployment template so the CI system can pass the exact build SHA at deploy time without touching any other configuration.
  • A chart author nests database configuration under a .Values.db key so operators can override only the database section without worrying about the rest of the chart.
  • A developer uses helm get values my-release to inspect the values that were applied to a running release when diagnosing unexpected behaviour.

More examples

Read nested values in template

Accesses nested keys from .Values and applies defaults, showing how templates consume the values hierarchy.

Example Β· yaml
# templates/deployment.yaml
env:
  - name: DB_HOST
    value: {{ .Values.db.host | quote }}
  - name: DB_PORT
    value: {{ .Values.db.port | default 5432 | quote }}
  - name: APP_ENV
    value: {{ .Values.environment | default "production" | quote }}

Inspect applied values

Retrieves the values that were supplied to the release; --all also shows default values from the chart's values.yaml.

Example Β· bash
# See values used for a running release
helm get values my-app -n production
# Include chart defaults as well
helm get values my-app -n production --all

Use a structured values block

Groups related settings under named keys so templates and operators work with a logical, namespace values structure.

Example Β· yaml
# values.yaml
db:
  host: postgres.svc.cluster.local
  port: 5432
  name: appdb

cache:
  host: redis.svc.cluster.local
  port: 6379
  ttl: 300

Discussion

  • Be the first to comment on this lesson.
Working with .Values β€” Helm | SoundsCode