OpsCanary
kuberneteshelmPractitioner

Mastering Helm Hooks: Control Your Release Lifecycle

5 min read Official DocsSep 13, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

Helm hooks exist to give chart developers a powerful mechanism to intervene at key points in a release's lifecycle. This capability is crucial for ensuring that necessary operations—like database migrations or configuration adjustments—occur exactly when needed. For instance, during a helm install, the default lifecycle is straightforward: the user runs the command, templates are rendered, resources are loaded into Kubernetes, and the release object is returned. However, by implementing hooks such as pre-install and post-install, you can modify this flow to include additional logic that can be essential for your application’s stability and performance.

The mechanics of Helm hooks involve specific annotations that you add to your Kubernetes resources. For example, to define a resource as a hook, you use the annotation helm.sh/hook: post-install. You can also set a helm.sh/hook-weight to determine the order of execution among multiple hooks, which is sorted in ascending order. Additionally, the helm.sh/hook-delete-policy annotation allows you to specify when the hook resources should be deleted, such as after they succeed or before new hooks are created. This level of control can significantly enhance your deployment strategy.

In production, understanding the nuances of Helm hooks is vital. One major caveat is that if you create resources within a hook, you cannot rely on helm uninstall to remove them, which can lead to resource bloat if not managed properly. Also, be aware that the crd-install hook has been removed in Helm 3, shifting to a crds/ directory approach. This means you need to adapt your strategies accordingly. Always test your hooks thoroughly to avoid unexpected behaviors during deployments.

Key takeaways

  • Define hooks using the annotation `helm.sh/hook` to control release lifecycle events.
  • Use `helm.sh/hook-weight` to establish a deterministic order for executing multiple hooks.
  • Implement `helm.sh/hook-delete-policy` to manage the lifecycle of hook resources effectively.
  • Be cautious with resources created in hooks, as they won't be removed by `helm uninstall`.
  • Adapt to the removal of the `crd-install` hook by using the `crds/` directory in Helm 3.

Why it matters

In production, effective use of Helm hooks can prevent downtime and ensure smooth transitions during upgrades or installations. This control can be the difference between a successful rollout and a failed deployment.

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🔥 SEPTEMBER PROMOSponsor

35% off certifications and e-learning with code SEPT26BTS35, or 40% off bundles and instructor-led training with SEPT26BTS40. New this month: the MCPA (Model Context Protocol Associate) certification.

Claim the discount →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.