Standard Labels
Helm charts should attach the recommended Kubernetes app.kubernetes.io labels through a shared helper.
Kubernetes defines a set of recommended labels under the app.kubernetes.io/ prefix. Applying them consistently makes your resources discoverable by tools and dashboards.
The recommended set
app.kubernetes.io/name— the app name.app.kubernetes.io/instance— the release name (unique per install).app.kubernetes.io/version— the app version.app.kubernetes.io/managed-by— usuallyHelm.app.kubernetes.io/componentand/part-of— optional grouping.
Selector labels
Keep a smaller label helper for selectors (typically just name + instance). Selector labels must be stable — never include a version there, or upgrades break the selector.
Example
{{- define "mychart.selectorLabels" -}}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- define "mychart.labels" -}}
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version }}
{{ include "mychart.selectorLabels" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}When to use it
- A chart adds the recommended app.kubernetes.io/managed-by: Helm label to all resources so kubectl and monitoring tools can identify Helm-managed objects at a glance.
- A developer queries all Pods belonging to a specific Helm release using the app.kubernetes.io/instance label, which every well-formed chart template attaches.
- A platform team enforces the standard labels by reviewing chart PRs and rejecting any template that omits app.kubernetes.io/name or app.kubernetes.io/version.
More examples
Standard labels helper
Defines all five recommended Kubernetes labels in one helper so every resource gets consistent, spec-compliant labels.
{{/* _helpers.tpl */}}
{{- define "myapp.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}Apply labels to a Deployment
Attaches the full label set to the Deployment metadata and uses a narrower selector-labels helper for the Pod selector.
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "myapp.fullname" . }}
labels:
{{- include "myapp.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "myapp.selectorLabels" . | nindent 6 }}Query resources by instance label
Uses the standard labels to filter Kubernetes resources by release instance or chart name across a namespace.
kubectl get pods \
-l app.kubernetes.io/instance=my-release \
-n production
kubectl get all \
-l app.kubernetes.io/name=myapp \
-n production
Discussion