OpsCanary
kuberneteshelmPractitioner

Mastering Helm Hooks: Control Your Release Lifecycle

5 min read Official DocsOct 18, 2026Reviewed for accuracy
Share
Practitioner — Hands-on experience recommended

Helm hooks exist to give chart developers a way to intervene at specific points in a release's lifecycle. This capability is crucial for automating tasks that need to happen before or after a release, such as database migrations or cleanup jobs. Without hooks, you might find yourself manually managing these tasks, which can lead to inconsistencies and errors in production.

The hooks mechanism works by allowing you to define operations at strategic points. For instance, during a helm install, the default lifecycle includes steps like rendering templates and loading resources into Kubernetes. By implementing hooks like pre-install and post-install, you can alter this lifecycle to include waiting for hooks to be 'Ready'. You can configure hooks using specific annotations like helm.sh/hook, helm.sh/hook-weight, and helm.sh/hook-delete-policy. The hook-weight parameter ensures that hooks execute in a deterministic order, while the hook-delete-policy defines when to clean up the resources created by the hooks.

In production, understanding the blocking nature of hooks is essential. For example, if you create resources in a hook, you can't rely on helm uninstall to remove them automatically. This can lead to resource bloat if not managed properly. Additionally, note that the crd-install hook has been removed in Helm 3, so you'll need to use the crds/ directory instead. Helm 3.2.0 introduced a change where hook resources with the same weight are installed in the same order as non-hook resources, which can affect your deployment strategy if you’re upgrading from earlier versions.

Key takeaways

  • →Define hooks using the annotation 'helm.sh/hook' to control execution points.
  • →Use 'helm.sh/hook-weight' to establish a deterministic order for your hooks.
  • →Implement 'helm.sh/hook-delete-policy' to manage the lifecycle of hook resources effectively.
  • →Be aware that hooks can block the Helm client, impacting deployment speed.
  • →Avoid relying on 'helm uninstall' to clean up resources created by hooks.

Why it matters

In production, effective use of Helm hooks can automate critical tasks, reducing manual intervention and minimizing errors during deployment. This leads to more reliable and consistent application behavior across environments.

Code examples

YAML
1apiVersion:batch/v1
2kind:Job
3metadata:
4  name: "{{ .Release.Name }}"
5  labels:
6    app.kubernetes.io/managed-by: {{.Release.Service | quote}}
7    app.kubernetes.io/instance: {{.Release.Name | quote}}
8    app.kubernetes.io/version: {{.Chart.AppVersion}}
9    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
10  annotations:
11    "helm.sh/hook": post-install
12    "helm.sh/hook-weight": "-5"
13    "helm.sh/hook-delete-policy": hook-succeeded
14spec:
15  template:
16    metadata:
17      name: "{{ .Release.Name }}"
18      labels:
19        app.kubernetes.io/managed-by: {{.Release.Service | quote}}
20        app.kubernetes.io/instance: {{.Release.Name | quote}}
21        helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
22    spec:
23      restartPolicy: Never
24      containers:
25        - name: post-install-job
26          image: "alpine:3.3"
27          command: ["/bin/sleep", "{{default "10" .Values.sleepyTime}}"]
YAML
annotations:
  "helm.sh/hook": post-install,post-upgrade
YAML
annotations:
  "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
Linux Foundation🔥 OCTOBER PROMOSponsor

35% off the CKA and other certifications with code OCT26NONCYBER, or 40% off Kubernetes security certs (CKS, KCSA) with OCT26CYBER.

Claim the discount →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.