OpsCanary
kuberneteshelmPractitioner

Mastering Helm Hooks: Control Your Release Lifecycle

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

Helm hooks exist to give chart developers the ability to intervene at strategic points in a release's lifecycle. This is crucial for managing complex deployments where certain operations must occur before or after the main resources are created. For instance, when you run helm install foo, the default lifecycle is straightforward. However, by implementing hooks like pre-install and post-install, you can modify this flow to include necessary checks or additional resource creation, ensuring everything is in place before the release is finalized.

To configure a hook, you use annotations in your resource definitions. The key parameters include helm.sh/hook, which defines the resource as a hook, and helm.sh/hook-weight, which establishes the order of execution for multiple hooks. For example, a post-install hook can be defined with a weight that ensures it runs after other hooks. Additionally, helm.sh/hook-delete-policy controls when the hook resources are deleted, allowing for cleanup based on your needs. Be aware that hooks can block operations; the Helm client will wait for a job to complete before proceeding, which can impact deployment speed.

In production, remember that hooks can introduce complexity. If you create resources within a hook, they won't be automatically cleaned up with helm uninstall, leading to potential resource bloat. Also, note that the crd-install hook has been deprecated in Helm 3, so adjust your charts accordingly. Understanding these nuances will help you leverage hooks effectively while avoiding common pitfalls.

Key takeaways

  • Use `helm.sh/hook` to define resources that should act as hooks.
  • Set `helm.sh/hook-weight` to control the execution order of multiple hooks.
  • Implement `helm.sh/hook-delete-policy` to manage cleanup of hook resources.
  • Be aware that hooks can block Helm operations, impacting deployment speed.
  • Remember that resources created in hooks won't be removed by `helm uninstall`.

Why it matters

In production, effective use of Helm hooks can streamline complex deployments and ensure that necessary operations occur at the right times, reducing the risk of failures and improving 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    # This is what defines this resource as a hook. Without this line, the
12    # job is considered part of the release.
13    "helm.sh/hook": post-install
14    "helm.sh/hook-weight": "-5"
15    "helm.sh/hook-delete-policy": hook-succeeded
16spec:
17  template:
18    metadata:
19      name: "{{ .Release.Name }}"
20      labels:
21        app.kubernetes.io/managed-by: {{.Release.Service | quote}}
22        app.kubernetes.io/instance: {{.Release.Name | quote}}
23        helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
24    spec:
25      restartPolicy: Never
26      containers:
27        - name: post-install-job
28          image: "alpine:3.3"
29          command: ["/bin/sleep", "{{default "10" .Values.sleepyTime}}"]
YAML
annotations:
  "helm.sh/hook": post-install,post-upgrade
YAML
annotations:
  "helm.sh/hook-weight": "5"

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.