CKAD · 24 November 2026 · 7 min read

Helm hooks vs init containers: which one should you use?

Init containers run on every Pod start; Helm hooks run once per release. When to use each for migrations, waiting on a database and cleanup, how they behave in Argo CD, and the questions people ask.

Helm hooks and init containers both run something before your application, so they often get suggested for the same jobs: run a database migration, wait for a dependency, seed some data. They work at different levels, though. An init container belongs to a Pod and runs every time that Pod starts. A Helm hook belongs to a release and runs once at a point in its lifecycle, such as before an install or after an upgrade. Choose by asking how often the work should happen.

TL;DR

  • Init container: part of the Pod spec. It runs before the app containers on every Pod start, in every replica. Kubernetes runs it, so it works the same whether you deploy with Helm, Kustomize, kubectl apply or Argo CD.
  • Helm hook: an ordinary resource (usually a Job) with a helm.sh/hook annotation. It runs once per helm install, upgrade, rollback, uninstall or test. Only Helm, or a tool that copies its behavior, runs it.
  • Waiting for a dependency, or preparing files for one Pod: init container.
  • One-off release work, such as a schema migration, a backup before an upgrade or a cleanup on uninstall: Helm hook (a Job).
  • Helm does not track hook resources as part of the release, so helm uninstall does not remove them. Set a delete policy.

What is an init container?

An init container is listed under spec.initContainers in a Pod (or a Pod template in a Deployment). Init containers run one at a time, in order, and each must exit 0 before the next starts. The app containers start only when every init container has finished. Our init containers guide covers them in detail. This one waits until PostgreSQL accepts connections:

Shell
spec:  initContainers:  - name: wait-for-db    image: postgres:17    command: ['sh', '-c', 'until pg_isready -h db -p 5432; do echo waiting for db; sleep 2; done']  containers:  - name: app    image: registry.example.com/shop:1.4.0

A Deployment with three replicas runs this init container three times, once per Pod. It runs again every time a Pod is recreated: after a rollout, a node drain, an eviction, or when an autoscaler adds a replica.

What is a Helm hook?

A Helm hook is any resource in a chart's templates/ folder with a helm.sh/hook annotation. Helm takes it out of the normal install and creates it at the named moment instead. This Job runs migrations before the chart's other resources are created on install, and before they are changed on upgrade:

YAML
apiVersion: batch/v1kind: Jobmetadata:  name: {{ .Release.Name }}-migrate  annotations:    "helm.sh/hook": pre-install,pre-upgrade    "helm.sh/hook-weight": "0"    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeededspec:  backoffLimit: 2  template:    spec:      restartPolicy: Never      containers:      - name: migrate        image: registry.example.com/shop:{{ .Chart.AppVersion }}        command: ['./shop', 'migrate', 'up']

The hooks are pre-install, post-install, pre-upgrade, post-upgrade, pre-rollback, post-rollback, pre-delete, post-delete and test. When a hook is a Job or a Pod, Helm waits for it to run to completion. If it fails, the release fails. A failed pre-upgrade hook therefore stops the upgrade before any of your Deployments change.

Side by side

  • Who runs it: the kubelet runs init containers. Helm runs hooks.
  • How often: an init container runs once per Pod start. A hook runs once per Helm operation.
  • With 5 replicas: 5 init container runs, at the same time, against 1 hook run.
  • Blocks: an init container blocks its own Pod. A pre-hook blocks the whole release.
  • Without Helm: an init container works anywhere. A hook is just an annotation that nothing else reads (Argo CD is the exception; see below).
  • Cleanup: an init container goes away with its Pod. A hook resource stays until its delete policy removes it.
  • Identity: an init container shares the Pod's ServiceAccount. A hook Job can have its own.

Common questions

Should database migrations run in an init container or a Helm hook?

Usually a hook, or a plain Job run by your pipeline. A migration should run once per release. In an init container it runs in every replica at the same time, and again whenever a Pod restarts or the Deployment scales out. That can work if your migration tool takes a lock in the database and does nothing when the schema is already current, and many tools do. But you are relying on the tool to make concurrent runs safe, and every new Pod waits on a migration check. A pre-upgrade hook Job runs once, and a failure stops the release before new code goes out.

Does a pre-upgrade hook mean no old Pods are running during the migration?

No. The old Pods keep serving while the hook runs, and old and new Pods overlap during the rolling update that follows. Write migrations that the old version can live with: add columns and tables first, and remove old ones in a later release. This applies to init containers too.

Which should I use to wait for a database or another Service?

An init container. Waiting belongs to the Pod that needs the dependency. It should also happen every time that Pod starts, because the database may be down when a Pod is rescheduled at 3 a.m., not only during a release. A hook only checks once, during helm install.

My pre-install hook cannot find a Secret from my chart. Why?

A pre-install hook runs after the templates are rendered but before any of the chart's resources are created. The Secret or ConfigMap it reads does not exist yet. Either create that Secret outside the chart, or make the Secret a hook too, with a lower helm.sh/hook-weight (hooks run in ascending weight order, and weights are strings, such as "-5").

Why is my old migration Job still in the cluster?

Helm does not track hook resources as part of the release, so helm uninstall leaves them behind. Use helm.sh/hook-delete-policy:

  • before-hook-creation deletes the previous copy before the hook runs again. It is the default when you set no policy.
  • hook-succeeded deletes it once it succeeds.
  • hook-failed deletes it if it fails. Leave this one out if you want to read the logs of a failed run.

Do post-install hooks wait for my Pods to be ready?

Only with --wait. With it, Helm waits for the release's resources to be ready before it runs post-install. Without it, the post-install hook can run while your Pods are still pulling images.

Do Helm hooks run in Argo CD?

Partly. Argo CD does not run helm install. It renders the chart and syncs the result. It maps pre-install and pre-upgrade to its PreSync phase, post-install and post-upgrade to PostSync, and the delete hooks to PreDelete and PostDelete. It skips test hooks. Argo CD has no separate install step, because every operation is a sync. A pre-install-only hook therefore runs on later syncs too. If a chart also has Argo CD's own hook annotations, Argo CD ignores all the Helm hooks. Init containers behave the same everywhere, which is one reason teams on GitOps prefer them for anything that must always run.

Which is more secure?

A hook Job can be. Every container in a Pod, init containers included, runs as the Pod's ServiceAccount and shares its volumes. A migration in an init container needs database credentials that can change the schema, so those credentials sit in the same Pod as your long-running app. A hook Job can run as its own ServiceAccount, with its own Secret for a schema-owner database user, and be deleted when it finishes. The app then connects as a user that can only read and write data. Fewer powerful credentials sitting in running Pods means less for an attacker to find.

Can I skip hooks?

Yes: helm install, upgrade, rollback and uninstall all take --no-hooks. You cannot skip an init container. Remove it from the Pod spec instead.

How do I debug each one?

An init container: kubectl get pod shows Init:0/1 or Init:CrashLoopBackOff; then run kubectl logs <pod> -c <init-container>. A hook: helm status <release> shows the failure, and kubectl logs job/<release>-migrate shows the Job's output, as long as a hook-failed delete policy has not already removed it.

Is this in the CKA or CKAD exam?

Init containers are core CKAD material (Application Design and Build) and a common cause of Pods stuck in Init in CKA troubleshooting. The exams expect you to install, upgrade and roll back Helm releases, not to write hooks. Still, knowing why a release is stuck on a hook Job saves time. See Helm explained for the commands.

A rule of thumb

Ask "should this happen every time a Pod starts, or once per release?" Every Pod start: an init container. Once per release: a Helm hook Job, or a Job that your pipeline or Argo CD runs in a sync wave. If you do not use Helm at all, the same split applies with Kustomize: an init container in the Pod, a Job for one-off work.

Keep going

In the Gazeek CKAD Helm and Kustomize module you ship apps with Helm and Kustomize on a real cluster, and the Pods module starts with multi-container Pods. For more on Pod helpers, see init containers and sidecar containers. Read on with Helm explained, Kustomize explained and Helm vs Kustomize.

More from the blog