Helm Charts in Production: Structure, Templating, Registry
Run Helm charts in production Kubernetes: chart structure, templating, values, dependencies, hooks, secrets, OCI registries, and safe upgrades.
Introduction
helm install on a sample chart takes two minutes. Running Helm in production is the part nobody demos: charts that roll back cleanly when an upgrade goes sideways, secrets that never touch values.yaml, versions pinned so a transitive update can’t break a Friday deploy, and releases you can actually debug at 3 a.m.
This guide covers chart anatomy, templating, values layering, dependencies and hooks — plus the parts most tutorials skip: secrets management, upgrade strategy, OCI registries, and testing charts before they reach a cluster. Templating fundamentals also live in Package Kubernetes Manifests with Helm Charts.
When Helm Is the Wrong Tool
- One static manifest set. If your app deploys identical YAML everywhere, plain
kubectl applyor Kustomize has less machinery. - GitOps-first teams. Argo CD and Flux can render Helm charts themselves — hand-rolling
helm upgradein CI duplicates their release tracking (see the GitOps guide for that path). - Deeply dynamic config. If operators generate manifests from live cluster state, a real operator or a config-management tool beats templating.
Helm earns its complexity when the same workload ships to three environments with different sizing, when releases need history and one-command rollback, and when a team packages an app for other teams to install. If none of that is true, the template engine is overhead you’re carrying for a use case you don’t have.
Chart Structure
my-app/
├── Chart.yaml # Chart metadata (name, version, dependencies)
├── values.yaml # Default configuration values
├── values-prod.yaml # Environment-specific overrides
├── charts/ # Dependency charts (vendored)
├── templates/
│ ├── _helpers.tpl # Named templates (reusable partials)
│ ├── deployment.yaml # Kubernetes Deployment
│ ├── service.yaml # Kubernetes Service
│ ├── ingress.yaml # Kubernetes Ingress
│ ├── configmap.yaml # ConfigMap for app config
│ ├── secret.yaml # Secret (encoded values)
│ ├── hpa.yaml # HorizontalPodAutoscaler
│ ├── pdb.yaml # PodDisruptionBudget
│ ├── serviceaccount.yaml # ServiceAccount + RBAC
│ └── NOTES.txt # Post-install instructions
├── templates/tests/
│ └── test-connection.yaml # Helm test pod
└── .helmignore # Files to exclude from chart package
Chart.yaml
# Chart.yaml
apiVersion: v2
name: my-app
description: A production web application chart
type: application
version: 1.2.3 # Chart version (SemVer)
appVersion: "2.1.0" # Application version
icon: https://example.com/icon.png
home: https://github.com/example/my-app
sources:
- https://github.com/example/my-app
maintainers:
- name: DevOps Team
email: devops@example.com
keywords:
- web
- api
- microservice
dependencies:
- name: postgresql
version: "12.12.10"
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: redis
version: "17.11.3"
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
Two version fields that people conflate: version is the chart’s own SemVer — bump it on every chart change, because rollbacks and OCI tags key off it. appVersion is informational metadata about the app you’re shipping; the convention is to default image.tag to it, which is exactly what {{ .Values.image.tag | default .Chart.AppVersion }} does in the deployment template below. Dependency version fields accept ranges, but pinning exact versions (12.12.10, not 12.x.x) is what keeps helm dependency update from surprising you.
Templating
Helper templates
# templates/_helpers.tpl — Reusable named templates
{{- define "my-app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "my-app.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "my-app.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
{{ include "my-app.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- define "my-app.selectorLabels" -}}
app.kubernetes.io/name: {{ include "my-app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- define "my-app.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{- default (include "my-app.fullname" .) .Values.serviceAccount.name -}}
{{- else -}}
{{- default "default" .Values.serviceAccount.name -}}
{{- end -}}
{{- end -}}
Templating details that bite in production: {{- strips whitespace before the tag (that’s why helpers start with {{- define), nindent N inserts a newline plus N spaces so YAML stays aligned, and unquoted values like {{ .Values.port }} render fine until someone sets a boolean-looking string — | quote on anything ambiguous is cheap insurance.
Deployment template
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "my-app.fullname" . }}
labels:
{{- include "my-app.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "my-app.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "my-app.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "my-app.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.probes.enabled }}
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 5
periodSeconds: 5
{{- end }}
env:
- name: APP_ENV
value: {{ .Values.env | quote }}
{{- range $key, $val := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.volumeMounts }}
volumeMounts:
{{- toYaml .Values.volumeMounts | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Values
Default values
# values.yaml
replicaCount: 2
image:
repository: registry.io/my-app
tag: ""
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
create: true
annotations: {}
name: ""
podAnnotations: {}
podSecurityContext:
fsGroup: 1000
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
service:
type: ClusterIP
port: 8080
ingress:
enabled: false
className: nginx
annotations: {}
hosts:
- host: app.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: app-tls
hosts:
- app.example.com
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi
autoscaling:
enabled: false
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
probes:
enabled: true
env: production
extraEnv: {}
postgresql:
enabled: true
auth:
database: myapp
redis:
enabled: false
Environment-specific overrides
# values-prod.yaml
replicaCount: 3
image:
tag: "2.1.0"
pullPolicy: IfNotPresent
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 20
targetCPUUtilizationPercentage: 70
ingress:
enabled: true
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/rate-limit: "100"
tls:
- secretName: app-prod-tls
hosts:
- app.example.com
postgresql:
primary:
persistence:
size: 50Gi
storageClass: fast-ssd
The layering rule: values.yaml holds safe defaults that work on a fresh helm install in any environment — passwords excluded, which is why postgresPassword disappeared from the example above. Environment files override only what differs. -f flags compose left to right (-f values.yaml -f values-prod.yaml), and --set beats both for one-offs like image tags from CI.
Dependencies
# Update dependencies (downloads to charts/)
helm dependency update my-app/
# Build dependencies (fails if lock file is stale)
helm dependency build my-app/
# List dependencies
helm dependency list my-app/
Conditional dependencies
# In values.yaml — control which dependencies are enabled
postgresql:
enabled: true # Include PostgreSQL subchart
redis:
enabled: false # Skip Redis subchart
Cross-chart value overrides
# Override subchart values from parent
postgresql:
enabled: true
auth:
postgresPassword: "secure-password"
primary:
persistence:
size: 20Gi
image:
tag: "15.4.0"
Chart.lock pins resolved versions — commit it. A chart that builds with update today and pulls different subchart versions tomorrow is a deploy you can’t reproduce.
Hooks
# templates/hooks/post-install-job.yaml — Run after install
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "my-app.fullname" . }}-migrate
labels:
{{- include "my-app.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
template:
metadata:
labels:
{{- include "my-app.selectorLabels" . | nindent 8 }}
spec:
restartPolicy: Never
containers:
- name: migrate
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
command: ["npm", "run", "migrate"]
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ include "my-app.fullname" . }}-db
key: url
Hook types
pre-install: Before any resources are created
post-install: After all resources are created
pre-delete: Before any resources are deleted
post-delete: After all resources are deleted
pre-upgrade: Before any resources are updated
post-upgrade: After all resources are updated
pre-rollback: Before any resources are rolled back
post-rollback: After all resources are rolled back
test: When helm test is run
Two production caveats: hooks block the release until they finish — a hung migration Job hangs helm upgrade until --timeout, and --atomic won’t undo a migration that half-committed schema changes. Keep hooks idempotent and short, and prefer hook-delete-policy cleanup or every upgrade leaves dead Jobs behind.
Secrets Management
Base64 is not encryption, and values.yaml in git is not a secret store. The three workable patterns:
- External Secrets Operator: secrets live in Vault/AWS Secrets Manager; ESO syncs them into cluster Secrets. The chart references them by name — nothing sensitive in the chart at all. The default choice for most teams.
- Sealed Secrets (Bitnami): you commit encrypted secrets to git; only the cluster controller can decrypt. Fits GitOps workflows where everything must live in the repo.
- SOPS-encrypted values:
values-prod.enc.yamlencrypted with Mozilla SOPS, decrypted at deploy time. Works but adds a decrypt step to every pipeline.
Whichever you pick, the chart contract stays the same: secretKeyRef in templates, no plaintext anywhere.
Upgrades and Rollbacks
The flags that matter in production:
# Atomic upgrade — auto-rollback if anything fails
helm upgrade my-release my-app/ -f values-prod.yaml -n production \
--atomic --timeout 5m --wait --cleanup-on-fail
# Release history (revision numbers for rollback)
helm history my-release -n production
# Rollback to a specific revision
helm rollback my-release 3 -n production
--atomic implies --wait: Helm watches readiness and reverts on timeout or failure. --cleanup-on-fail deletes resources created during the failed upgrade so the retry doesn’t conflict. Rollbacks re-apply old manifests but don’t touch data — a migration hook that ran between revisions isn’t un-run, so test helm rollback in staging after any release that ships a migration, not the day you need it.
OCI Registries
Charts are OCI artifacts now — the same registry that hosts your images can host charts:
# Push
helm package my-app/ --version 1.2.3
helm push my-app-1.2.3.tgz oci://registry.io/charts/
# Pull
helm pull oci://registry.io/charts/my-app --version 1.2.3
# Depend on an OCI chart
# dependencies:
# - name: shared-lib
# version: "1.4.0"
# repository: oci://registry.io/charts
Classic index-based repos (helm repo add) still work, but OCI is where new infrastructure lands: auth, signing, and policy are the same as for images, and there’s no index.yaml to sync.
A versioning habit worth adopting early: tag the chart release, the OCI artifact, and the container image independently. The chart at 1.2.3 can ship appVersion 2.1.0 — bumping the chart version for a template fix shouldn’t force an image rebuild, and bumping appVersion for a hotfix shouldn’t require a chart change. Keep them honest in CI by failing the build when helm package would produce a tag that already exists in the registry.
Testing Charts
Three layers, cheapest first:
helm lint+helm templatein CI: catches YAML and template errors before they reach a cluster.helm unittest(helm-unittest plugin): snapshot-style assertions on rendered manifests — verify labels, replicas, securityContext without a cluster.- chart-testing (
ct lint/ct install): installs the chart into a real test cluster and runshelm testpods — the closest thing to a staging deploy in CI.
# tests/deployment_test.yaml (helm-unittest)
suite: deployment defaults
templates:
- deployment.yaml
tests:
- it: sets non-root security context
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext.runAsNonRoot
value: true
Helm Commands
# Install a chart
helm install my-release my-app/ -f values-prod.yaml -n production
# Upgrade a release
helm upgrade my-release my-app/ -f values-prod.yaml -n production
# Upgrade with atomic rollback on failure
helm upgrade my-release my-app/ -f values-prod.yaml -n production --atomic --timeout 5m
# Dry run (render templates without applying)
helm install my-release my-app/ -f values-prod.yaml --dry-run --debug
# Template rendering only
helm template my-release my-app/ -f values-prod.yaml > rendered.yaml
# List releases
helm list -n production
helm list -A # All namespaces
# Rollback to previous version
helm rollback my-release 3 -n production
# Uninstall
helm uninstall my-release -n production
# Package a chart
helm package my-app/ --version 1.2.3 --destination ./dist/
# Lint a chart
helm lint my-app/
# Run tests
helm test my-release -n production
Library Charts
# Chart.yaml for library chart
apiVersion: v2
name: common
type: library # Library chart — not deployable
version: 1.0.0
description: Shared templates for application charts
# templates/_deployment.tpl — Define reusable deployment template
{{- define "common.deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
labels:
app: {{ .Values.name }}
spec:
replicas: {{ .Values.replicas | default 2 }}
selector:
matchLabels:
app: {{ .Values.name }}
template:
metadata:
labels:
app: {{ .Values.name }}
spec:
containers:
- name: {{ .Values.name }}
image: {{ .Values.image }}
ports:
- containerPort: {{ .Values.port | default 8080 }}
{{- end -}}
# In application chart — use library
# templates/deployment.yaml
{{ include "common.deployment" . }}
Troubleshooting Stuck Releases
PENDING_UPGRADE/FAILEDafter a crashed upgrade:helm list -ashows it;helm rollbackto the last good revision clears the lock.- Hook Job never finishes: the upgrade hangs until
--timeout; check the Job’s pod logs, fix the cause, and delete the stuck Job before retrying. helm templatefine, install fails: template errors are render-time; admission webhooks and CRD ordering are apply-time —--dry-run=serversurfaces the latter.- Values that “don’t apply”: usually a typo’d key that silently does nothing —
helm get values my-releaseshows the resolved set. - Release installs but nothing works: compare
helm get manifestoutput with whatkubectl getactually shows; drift between them means something outside Helm changed the resources.
Best Practices
- Use
includeovertemplate— composable and chainable with pipes - Use
nindentoverindent— correct leading newlines in YAML - Requests and limits on every container — unbounded pods starve neighbors
--atomic --waiton every production deploy — failed upgrades roll back- Pin dependency versions exactly — ranges break at 2 a.m., not in review
chartVersionandappVersionmove independently — SemVer for the chart, app version for the artifact- External Secrets for sensitive values — never in
values.yaml helm lint+helm templatediff in CI before any mergehelm.sh/hook-delete-policyon every hook — completed Jobs are debris
Common Mistakes
- Secrets in values.yaml: base64 is encoding, not encryption — ESO, Sealed Secrets, or SOPS instead.
- No
--atomicin prod: a failed upgrade leaves a half-applied release and a manual cleanup. - Hardcoded image tags:
{{ .Values.image.tag }}ordefault .Chart.AppVersion— let CI set it. - Ranged dependency versions:
12.x.xresolves differently tomorrow; pin12.12.10. - Hooks that aren’t idempotent: a migration that can’t re-run turns every retry into a new incident.
- Skipping
helm lintin CI: YAML errors discovered at deploy time are the most expensive kind.
Production Checklist
The complete example chart ships in the companion repository: layered values, helpers, deployment template, migration hook, and unittest assertions.
-
helm lintandhelm templatediff in CI on every chart PR - Dependencies pinned exactly,
Chart.lockcommitted - No secrets in
values.yaml— ESO/Sealed Secrets/SOPS in place - Resource requests/limits, securityContext, probes templated
- Production deploys use
--atomic --wait --cleanup-on-fail - Hooks idempotent with
hook-delete-policy -
helm testpods run post-deploy in staging - Rollback tested in staging after schema-migrating releases
- Charts pushed to OCI registry with version tags
-
helm get valuesaudited — no stale overrides
See Also
- Package Kubernetes Manifests with Helm Charts
- Deploy Applications with Helm on Kubernetes
- Helm Chart Review Checklist
- Complete Guide to Kubernetes Config Management
- Complete Guide to GitOps with ArgoCD
- Helm documentation — official chart and hook reference
- chart-testing — lint and install charts in CI
- helm-unittest — manifest assertions without a cluster
Frequently Asked Questions
What is a Helm chart?
A package of templated Kubernetes manifests: Chart.yaml metadata, values.yaml defaults, and templates/ rendered from Go templates plus release history per install.
What is the difference between helm install and helm upgrade --install?
helm install creates a release and fails if it exists; upgrade --install upgrades it or creates it — the idempotent form CI/CD should use.
What are Helm hooks?
Annotated resources that run at release lifecycle points — post-install migrations, pre-delete cleanup, test for helm test. They block the release until they finish.
What is a library chart?
A type: library chart — reusable templates, not deployable. Application charts include it as a dependency and call its definitions with include.
How do I manage secrets in Helm?
Not in values.yaml. External Secrets Operator syncing from Vault/cloud stores, Sealed Secrets for GitOps, or SOPS-encrypted value files — the chart only references Secrets by name.
What's the difference between version and appVersion?
version is the chart's SemVer (bump on every chart change; rollbacks and OCI tags key off it). appVersion is metadata about the shipped app — conventionally the default image.tag.
Related Resources
Kubernetes Config Management Guide
Kubernetes configuration management: ConfigMaps, Secrets, External Secrets Operator, sealed secrets, env injection, mounts, and rotation.
GuideComplete Guide to CI/CD with GitHub Actions
Build CI/CD pipelines from scratch with GitHub Actions. Covers workflows, runners, matrix builds, caching, secrets, environments, deployment strategies, and reusable workflows.
GuideComplete Guide to GitOps with ArgoCD
Deploy Kubernetes apps with GitOps and ArgoCD: installation, ApplicationSets, sync strategies, Helm/Kustomize, RBAC, and multi-cluster.
RecipeHelm Chart Templating: Package Kubernetes Manifests
Build a production-ready Helm chart from scratch: values, helpers, conditionals, ranges, hooks, subcharts, packaging, and OCI registries.