Helm Hooks Are Release Glue, Not Application Logic
Use Helm hooks for short, release-coupled tasks such as pre-upgrade migrations. Learn when they fit and when they add risk.
26 Sept 2026, 03:24 UTC

The problem: migrations that run once per pod
A platform team packaged a database migration as an init container inside every service pod. On each upgrade, every replica attempted to run the migration at startup. With ten replicas, ten migration jobs hit the same schema at once, causing lock errors and failed rollouts. The team needed a task that runs once per release boundary, not once per pod start.
Helm hooks are annotated Kubernetes manifests that Helm creates at defined release points, such as pre-upgrade or post-install. They are lifecycle glue, not an application runtime. Used narrowly, they can run a migration or smoke check once per upgrade. Used carelessly, they couple release success to side effects Helm cannot always undo.
How hooks differ from init containers
An init container runs every time a Pod starts or restarts. That is right for setup that belongs to the Pod lifecycle, such as waiting for a config file. It is wrong for a schema migration that should run once per release.
A Helm hook is a manifest with annotations such as helm.sh/hook: pre-upgrade. Helm creates the hook resource before the release upgrade proceeds. Hook weight orders multiple hooks; lower weights run first. Hook deletion policy controls cleanup, for example removing a Job after it succeeds or before the next hook is created.
Supported hook points include pre-install, post-install, pre-upgrade, post-upgrade, pre-rollback, post-rollback, pre-delete, post-delete, and test. Exact behavior for flags such as --wait, --timeout, and --atomic varies by Helm version, so check the documentation for your installed version before relying on a specific rollback sequence.
Worked example: a pre-upgrade migration hook
This example assumes Helm 3 and a cluster where you have permission to create Jobs, ServiceAccounts, and RBAC rules in the target namespace.
Chart template
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "mychart.fullname" . }}-pre-upgrade-migration
annotations:
helm.sh/hook: pre-upgrade
helm.sh/hook-weight: "1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
template:
spec:
serviceAccountName: migration-hook
restartPolicy: Never
backoffLimit: 0
containers:
- name: migrate
image: {{ .Values.migration.image }}
command: ["/bin/migrate", "--up"]
Run the upgrade from a terminal with helm and kubectl configured for the cluster:
helm upgrade --install --atomic --timeout 10m my-release ./mychart
Where to run: your local workstation or CI runner with kubeconfig access. Required permissions: ability to create releases and Jobs in the namespace, plus RBAC for the hook's ServiceAccount. Placeholders: my-release, ./mychart, and 10m should match your release name, chart path, and acceptable wait time.
Expected check: the migration Job appears before new application Pods become ready. If the Job fails, Helm attempts to roll back the release where it can. Risk: a failed migration can still leave the database schema changed, and Helm rollback cannot reliably reverse changes outside Kubernetes.
RBAC for the hook
The hook Job should use a dedicated ServiceAccount with least-privilege rules. Hooks orchestrate resources; they do not replace RBAC, admission control, or image policy.
Helm test as a smoke check
Hooks of type test run when you execute helm test my-release. A test Pod that exits zero signals a successful smoke check. This is useful as a release gate or diagnostic, but it does not replace CI, integration tests, backups, or production observability.
When hooks are the wrong fit
| Approach | Best for | Avoid when |
|---|---|---|
| Helm hook | Short, idempotent, release-coupled steps such as schema migration or config validation | Non-idempotent data changes, manual approval gates, or multi-service coordination |
| Init container | Per-Pod startup setup | Tasks that must run once per release |
| External migration pipeline | Risky or coordinated data changes across services | Simple, single-service schema updates that fit in a release |
Limitations and how to verify
- Check your installed Helm version and read that version's hook documentation before using exact flags or deletion policies.
- Build a throwaway kind or minikube cluster and run a sample chart with one pre-upgrade Job hook and one test hook. Observe ordering, cleanup, failure, and rollback behavior directly.
- Run the upgrade twice to confirm the migration Job is idempotent.
- Confirm the hook Job's ServiceAccount has only the RBAC it needs, and confirm hook resources are removed under your chosen deletion policy.
Closing
Start with helm test smoke checks. Add a pre-upgrade hook only when the task is short, idempotent, and truly tied to the release boundary. If the migration is risky, non-repeatable, or shared across services, keep Helm for application artifacts and let a controlled migration pipeline own data changes.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.