Interview Prep/Helm/Hooks, Migrations & Testing

A migration hook needs the DB password, but the Secret is created by the same chart. Is that a problem?

AdvancedScenarioHooks, Migrations & Testing
Answer

Situation read → It depends on the hook event. On post-install and pre-upgrade of later releases the Secret already exists. On pre-install it does not.

What I'd do →

  1. Use post-install,pre-upgrade timing.
  2. If the password changes in this upgrade, the regular Secret is not yet updated at pre-upgrade; then also render the credentials into a hook Secret (lower weight) or avoid rotating secrets in the same release as migrations.
  3. Or use an ExternalSecret that exists independently of the release.

Why → Regular resources are applied after pre-* hooks.

Interview tip → "Pre hooks see the old state of regular resources" is the key insight.

All Helm questions Roadmap: Helm

More on Hooks, Migrations & Testing