How would you rotate a database password without downtime?
Short answer
Use a two-credential (dual-user or dual-password) approach: create the new credential while the old one still works, roll the new value out to all app instances, confirm nobody uses the old one, then revoke it. Managed tools like AWS Secrets Manager rotation automate this with alternating users.
Manual steps
- Create the new password (or a second user
orders_app_bwith the same grants). - Update the secret in the vault → External Secrets syncs the K8s Secret.
- Roll the pods (
kubectl rollout restart deploy/ordersor a tool like Stakater Reloader) so they pick up the new value; pools reconnect with the new credentials. - Verify all connections use the new credential (
pg_stat_activity/SHOW PROCESSLISTby user). - Revoke the old password/user.
Automated
AWS Secrets Manager rotation Lambda (alternating-users strategy) switches between two DB users, so one is always valid; apps that read the secret on each new connection never see an outage.
Common failure
Changing the password directly on the database first → every pod with the old password fails immediately. Always make the new one valid before removing the old.
What to say in the interview
"Overlap the credentials: create the new one, update the vault, roll pods via External Secrets and a reloader, verify sessions moved over, then revoke the old one. Secrets Manager's alternating-users rotation automates exactly this."