OpsCanary
kuberneteshelmPractitioner

Mastering Helm Hooks: Control Your Release Lifecycle

5 min read Official DocsJun 14, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

Helm hooks exist to give chart developers the power to intervene at key moments during a release's lifecycle. This capability is crucial for ensuring that necessary operations, such as database migrations or configuration adjustments, are executed at the right time. For instance, during a helm install, the default lifecycle is straightforward: the user runs the command, Helm processes the templates, and resources are loaded into Kubernetes. However, by implementing hooks like pre-install and post-install, you can modify this flow to include waiting for certain conditions to be met before proceeding.

To configure hooks, you use specific annotations in your Kubernetes resource definitions. The key parameters include helm.sh/hook, which defines the resource as a hook, and helm.sh/hook-weight, which allows you to set a deterministic order for execution. For example, a job can be defined as a post-install hook with a weight of -5, ensuring it runs after other hooks with higher weights. Additionally, the helm.sh/hook-delete-policy annotation determines when to clean up the hook resources, which is essential for managing your cluster's state effectively. Be cautious, though: if you create resources in a hook, you cannot rely on helm uninstall to remove them, as noted in the removal of the crd-install hook in Helm 3.

In production, understanding the nuances of Helm hooks is vital. They can streamline your deployment processes, but they also introduce complexity. Always test your hooks thoroughly to avoid unexpected behaviors. Remember that the version you're using can impact available features, so keep an eye on updates and changes in Helm's behavior as you upgrade.

Key takeaways

  • Define hooks using the annotation `helm.sh/hook` to control lifecycle events.
  • Set hook weights with `helm.sh/hook-weight` for deterministic execution order.
  • Implement hook deletion policies using `helm.sh/hook-delete-policy` to manage resource cleanup.
  • Be aware that resources created in hooks won't be removed by `helm uninstall`.

Why it matters

In production, the ability to control the release lifecycle with hooks can prevent downtime and ensure that critical operations are performed in the right sequence, enhancing overall reliability.

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 →
Better StackSponsor

Unified observability — logs, uptime monitoring, and on-call in one place. Used by 50,000+ engineering teams to ship faster and sleep better.

Try Better Stack free →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.