Hook Deletion Policies
Cleaning up hook resources after they succeed.
Hook Deletion Policies is a free Helm Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Hooks Linger
By default a hook resource stays in the cluster after it runs. Without cleanup, old migration Jobs and pods pile up release after release.
The Delete Policy
You control cleanup with the helm.sh/hook-delete-policy annotation. It tells Helm exactly when to remove a hook resource it created.
annotations:
"helm.sh/hook-delete-policy": hook-succeededDelete on Success
The most common choice is hook-succeeded. Helm deletes the hook resource right after it completes successfully, keeping the namespace tidy.
"helm.sh/hook-delete-policy": hook-succeededKeep Failures for Debugging
With hook-succeeded, a failed hook is left behind on purpose. You can read its logs to see why the migration broke before cleaning up by hand. 🔍
Delete on Failure
The opposite policy is hook-failed. Helm removes the hook resource only when it fails, which suits hooks you would rather not leave around broken.
"helm.sh/hook-delete-policy": hook-failedDelete Before the Next Run
The third option is before-hook-creation. Helm deletes a previous instance just before creating the new one, sidestepping immutable-name collisions.
"helm.sh/hook-delete-policy": before-hook-creationThe Default Behavior
If you set no policy at all, Helm uses before-hook-creation by default. The old hook is cleared right before the next run recreates it.
Combine Policies
Policies can be combined in a comma-separated list. Pairing before-hook-creation with hook-succeeded clears stale runs and tidies up after each success.
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeededSolving Immutable Jobs
A Job's spec cannot be changed once created. before-hook-creation avoids that by deleting the old Job first, so each upgrade gets a fresh one.
Choose by Intent
Pick the policy that matches your goal: clean up on success, keep evidence of failures, or always start fresh. Each annotation just answers when to delete.
Helm Owns the Cleanup
These policies only apply to resources Helm created as hooks. Helm tracks them and deletes them for you, so you avoid manual kubectl delete after every release.
Quick Check
You want a migration Job removed automatically once it finishes successfully.
Recap
The hook-delete-policy picks when Helm removes a hook: on success, on failure, or before the next creation. The default is before-hook-creation. 🧹
Frequently asked questions
Is the “Hook Deletion Policies” lesson free?
Yes — the full text of “Hook Deletion Policies” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.
What will I learn in “Hook Deletion Policies”?
Cleaning up hook resources after they succeed. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Helm Academy?
No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Hook Deletion Policies” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Helm Academy lesson?
Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.