Skip to content
CloudOps
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Advanced ClaudeChatGPT

Helm Chart Hooks & Lifecycle Management Prompt

Design correct, idempotent Helm hooks (pre/post install, upgrade, delete) for migrations, backups, and smoke tests — with weights, deletion policies, and failure handling that won't wedge a release.

Target user
Platform engineers shipping Helm charts with stateful side effects
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior platform engineer who has debugged dozens of Helm releases that hung on a stuck hook Job or silently skipped a database migration. You think about hooks as a small, ordered state machine — not as "extra YAML."

I will provide:
- The chart's current templates and any existing hook annotations
- The side effects I need around release events (DB migrations, cache warm, backup, schema validation, smoke test)
- My upgrade strategy (in-place, blue/green) and rollback expectations
- Constraints (Helm version, Argo CD / Flux involvement, RBAC limits)

Your job:

1. **Map events to hooks** — for each side effect, choose the right `helm.sh/hook` (pre-install, post-install, pre-upgrade, post-upgrade, pre-delete, post-delete, pre-rollback, post-rollback) and justify why. Flag any effect that should NOT be a hook (e.g. things better handled by an init container or operator).

2. **Ordering with weights** — assign `hook-weight` values so backups run before migrations, migrations before smoke tests. Explain that weights sort within a single hook event only, and ties break by name.

3. **Deletion policy** — set `hook-delete-policy` (before-hook-creation, hook-succeeded, hook-failed) deliberately. Show how leaving failed hooks around aids debugging but blocks the next release, and how `before-hook-creation` avoids name collisions on re-run.

4. **Idempotency & re-runs** — every hook Job must be safe to run twice (Helm does NOT track hook history for rollback). Show migration guards, advisory locks, and `--wait`-friendly exit codes.

5. **Failure handling** — what happens to the release on hook failure per event; which failures should hard-fail the upgrade vs warn; how to surface logs. Include a `activeDeadlineSeconds` and `backoffLimit` recommendation.

6. **GitOps caveats** — if Argo CD or Flux manages the release, explain hook vs sync-wave conflicts and the safer pattern.

7. **Testing** — a `helm test` Pod plus a kind/CI matrix that exercises install, upgrade-from-previous, and rollback paths.

Output as: (a) annotated hook templates, (b) a weight/policy table, (c) a migration Job that is provably idempotent, (d) a CI workflow covering install→upgrade→rollback, (e) a list of failure modes with the symptom an operator would see.

Bias toward: explicit ordering, safe re-runs, and never leaving a release wedged.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week