Labels and Naming
Control resource names and labels in ohMyHelm Chart mode using nameOverride, fullnameOverride, applabel, chart.labels, chart.podLabels, and podAnnotations.
Labels and Naming
ohMyHelm provides consistent naming and labeling helpers in templates/_helpers.tpl. They let you control precisely how workloads, Services, Ingresses, ServiceAccounts, and pod selectors are named and labeled.
Naming (nameOverride and fullnameOverride)
Two helper templates determine all resource names in Chart mode:
ohmyhelm.name: Useschart.nameOverrideif set, otherwise.Chart.Name(ohmyhelm), truncated to at most 63 characters. This value populates the standard labelapp.kubernetes.io/name.ohmyhelm.fullname: Useschart.fullnameOverrideif set. Otherwise, uses<Release.Name>if<Release.Name>already containsohmyhelm.name, or<Release.Name>-<ohmyhelm.name>otherwise (truncated to at most 63 characters).
| Setting | ohmyhelm.name (app.kubernetes.io/name) |
ohmyhelm.fullname (Workload, Service, Ingress Name) |
|---|---|---|
No overrides, release acme |
ohmyhelm |
acme-ohmyhelm |
nameOverride: "api", release acme |
api |
acme-api |
fullnameOverride: "acme-api" |
ohmyhelm |
acme-api |
nameOverride: "acme-api" + fullnameOverride: "acme-api" |
acme-api |
acme-api |
Default Labels and chart.applabel
Every workload and Service automatically receives ohmyhelm.labels and ohmyhelm.selectorLabels:
# Default labels (ohmyhelm.labels)
helm.sh/chart: ohmyhelm-<chartVersion>
app.kubernetes.io/name: <ohmyhelm.name>
app.kubernetes.io/instance: <Release.Name>
app: <ohmyhelm.fullname> # only when chart.applabel: true (default!)
app.kubernetes.io/version: "<appVersion>"
app.kubernetes.io/managed-by: Helm
The chart.applabel switch defaults to true and adds the app: <ohmyhelm.fullname> label directly to ohmyhelm.selectorLabels. As a result, it automatically appears on:
metadata.labelsof the workload and Servicespec.selector.matchLabelsof the workloadspec.template.metadata.labelsof the podsspec.selectorof the Service
This ensures Service selectors, NetworkPolicies, and kubectl get pods -l app=<fullname> work without extra configuration.
Custom Labels (chart.labels and chart.podLabels)
You can add your own labels through two separate dictionaries:
chart.labels: Added tometadata.labelsof theDeployment,StatefulSet, orDaemonSet.chart.podLabels: Added tospec.template.metadata.labelsof the generated pods (useful for NetworkPolicies, PodMonitor, or logging filters).
Additional pod annotations are set via chart.podAnnotations.
Complete Example
chart:
enabled: true
nameOverride: "acme-checkout"
fullnameOverride: "acme-checkout"
applabel: true
labels:
app.kubernetes.io/part-of: acme-shop
app.kubernetes.io/component: backend
podLabels:
team: checkout
tier: backend
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
container:
image: registry.acme.corp/checkout:1.5.0
ports:
- name: http
containerPort: 8080
protocol: TCP
Resulting Metadata in the Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: acme-checkout
labels:
helm.sh/chart: ohmyhelm-1.18.0
app.kubernetes.io/name: acme-checkout
app.kubernetes.io/instance: acme-release
app: acme-checkout
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: acme-shop
app.kubernetes.io/component: backend
spec:
selector:
matchLabels:
app.kubernetes.io/name: acme-checkout
app.kubernetes.io/instance: acme-release
app: acme-checkout
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
labels:
app.kubernetes.io/name: acme-checkout
app.kubernetes.io/instance: acme-release
app: acme-checkout
team: checkout
tier: backend