Interview Prep/Helm/Hooks, Migrations & Testing

A hook Job keeps failing with "already exists" on the second deploy. Why?

BeginnerScenarioHooks, Migrations & Testing
Answer

Situation read → The first run's Job still exists, and Jobs are immutable, so Helm cannot create a new one with the same name.

What I'd do →

  1. Add "helm.sh/hook-delete-policy": before-hook-creation.
  2. Delete the stale Job once: kubectl delete job shop-migrate -n shop.

Why → before-hook-creation removes the previous instance before each run.

Interview tip → Note it is the default only when no delete policy annotation is set.

All Helm questions Roadmap: Helm

More on Hooks, Migrations & Testing