Interview Prep/Helm/Hooks, Tests, GitOps & Secrets

The migration hook fails with `psql: error: connection to server at "shop-postgres" (10.96.12.4), port 5432 failed: Connection refused` on first install.

IntermediateTroubleshootingHooks, Tests, GitOps & Secrets
Answer

Likely causes → The hook runs as pre-install (DB does not exist yet), or as post-install without --wait and before Postgres is ready.

Diagnose → helm get hooks shop -n shop | grep 'helm.sh/hook:'; kubectl get pods -n shop timestamps.

Fix → Use post-install,pre-upgrade and add an init container that loops on pg_isready -h shop-postgres -p 5432 before migrating.

Prevent → Treat DB readiness as an explicit dependency in hooks.

All Helm questions Roadmap: Helm

More on Hooks, Tests, GitOps & Secrets