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 →
- Use
post-install,pre-upgradetiming. - 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. - 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.
More on Hooks, Migrations & Testing
Design database migrations for a Helm-deployed app where the database is a subchart.IntermediateThe migration Job takes 12 minutes on prod data and the upgrade times out. What do you change?IntermediateA migration hook failed and the Job pod was deleted, so you cannot see why. How do you fix the chart?BeginnerYou want a backup before every production upgrade. How do you do it with Helm?IntermediateA `post-install` hook seeds demo data; it ran again on every upgrade and duplicated rows. Why?IntermediateHow do you clean up external resources (DNS records, S3 buckets) when a release is uninstalled?Advanced