OpsCanary
kuberneteshelmPractitioner

Mastering Helm Hooks: Control Your Release Lifecycle

5 min read Official DocsMay 24, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

Helm hooks exist to give you, the chart developer, control over the release lifecycle. They allow you to perform operations at strategic points, such as before or after an installation. This is crucial for managing complex deployments where certain tasks must be completed before or after the main resources are created. For example, during a helm install, the default lifecycle can be extended by implementing hooks that execute at specific times, like pre-install and post-install.

To configure hooks, you use annotations in your resource definitions. The key parameters include helm.sh/hook, which defines the resource as a hook, helm.sh/hook-weight, which sets the execution order of hooks, and helm.sh/hook-delete-policy, which determines when to delete the hook resources. For instance, a post-install job can be defined with a weight to ensure it runs after other hooks. Be aware that the crd-install hook has been removed in Helm 3, and this is a blocking operation, meaning the Helm client will pause until the job completes. Additionally, if you create resources in a hook, you cannot rely on helm uninstall to clean them up, which can lead to resource clutter if not managed properly.

In production, understanding the implications of hook execution is vital. You need to consider the blocking nature of hooks and the potential for resource leakage if not handled correctly. Starting from Helm 3.2.0, hooks with the same weight are installed in the same order as non-hook resources, which can simplify your deployment logic. Always test your hooks thoroughly to ensure they behave as expected in your specific environment.

Key takeaways

  • Define hooks using the annotation `helm.sh/hook` to control lifecycle events.
  • Use `helm.sh/hook-weight` to establish a deterministic execution 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, affecting deployment speed.
  • Remember that resources created in hooks won't be cleaned up by `helm uninstall`.

Why it matters

In production, effective use of Helm hooks can streamline complex deployments and ensure that necessary operations are completed at the right times. This control can prevent failures and improve the reliability of your applications.

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.