Use a Helm release name in chart values and templates

Keep ordinary values as data, build names in templates, or explicitly evaluate a trusted template string with tpl.

Best practices
Illustration of container operations and troubleshooting

Helm does not automatically evaluate template expressions inside values.yaml. A quoted value such as "{{ .Release.Name }}-app" remains a string unless a chart template explicitly evaluates it with tpl. For ordinary resource naming, constructing the name in the template is usually clearer.

Build the name in a template

With this value:

# values.yaml
nameSuffix: app

A template can combine it with the release name:

# templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ printf "%s-%s" .Release.Name .Values.nameSuffix | quote }}
data:
  purpose: "Example configuration"

The chart needs its normal Chart.yaml as well. Rendering with helm template myrel ./chart produces a name such as myrel-app. Choose values that satisfy the relevant Kubernetes naming rules; quoting YAML does not make an invalid resource name valid.

.Release belongs to the template context. Inside a with or range that changes the current dot, use the retained root context, commonly $.Release.Name, or pass the intended context into a helper.

Centralize naming in a helper

{{- define "examplechart.fullname" -}}
{{- printf "%s-%s" .Release.Name .Values.nameSuffix | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Store this in templates/_helpers.tpl, then use {{ include "examplechart.fullname" . | quote }} wherever that name is needed. Prefix named helpers with a chart-specific name because named templates share a namespace.

This helper illustrates a 63-character convention used for many Kubernetes names and labels. Different fields have different constraints, and truncation can create collisions. Keep selectors and Pod labels consistent with the naming scheme rather than changing them independently during an upgrade.

Explicitly render a value with tpl

A chart can deliberately support templated values:

# values.yaml
appName: "{{ .Release.Name }}-app"

In the template, compare these two expressions:

{{ .Values.appName | quote }}
{{ tpl .Values.appName . | quote }}

The first returns the literal braces. The second evaluates the string using the supplied context and returns the release-derived name. This is an opt-in chart feature, not automatic interpolation or recursive evaluation of every value.

Treat values evaluated with tpl as template code from a trusted source. Template functions, including cluster lookups in applicable rendering modes, can do more than concatenate text. Do not introduce tpl merely to process arbitrary untrusted input.

Command-line overrides and validation

helm template myrel ./chart --set-string nameSuffix=worker
helm lint ./chart

A chart may also support fullnameOverride, but that is a chart-defined convention rather than a universal Helm setting. --set-string avoids unwanted type inference for string inputs. required can reject a missing value, and default can provide a fallback; neither automatically renders a template string.

Ordinary values cannot refer to another .Values entry by themselves. Compose the result in a template or explicitly use a documented tpl interface. Subcharts see the same release name, although their .Values scope differs.

Local rendering helps inspect YAML and names, but does not establish that a cluster will accept or successfully run the resulting resources. Review schema, permissions, and upgrade behavior separately.

See Helm template functions and tpl and Helm built-in objects.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting