As asked
Your production database password has leaked in a log file. Walk me through rotating it with zero downtime across a fleet of 200 application pods.
Sample answer outline
Two passwords on the database account, or a dual-credential pattern (Vault dynamic credentials or AWS RDS IAM auth). Sequence: add the new credential, push it to the secret store, trigger a rolling restart so pods pick it up via the projected secret or a sidecar, verify all pods are on the new credential, then revoke the old one. Audit logs to confirm no connections used the old credential before revoking. Treat the leak itself separately: rotate, then investigate scope.
Reference implementation (bash)
# Postgres supports a window where two passwords are valid (via pgbouncer auth_query
# or by issuing both old and new for the same role). For RDS IAM auth, no static
# password is needed at all.
# 1. Stage new credential in the secret manager
aws secretsmanager update-secret \
--secret-id prod/api/db \
--secret-string '{"username":"api","password":"NEW_PASSWORD"}'
# 2. Trigger a rolling restart so pods pick up the new secret
kubectl rollout restart deployment/api -n prod
kubectl rollout status deployment/api -n prod --timeout=10m
# 3. Confirm no active sessions are using the old credential
psql -c "select usename, count(*) from pg_stat_activity group by 1;"
# 4. Revoke the old credential on the database
psql -c "alter user api with password 'NEW_PASSWORD';"Expect these follow-ups
- What if your database does not support two simultaneous passwords?
- How do you prove the leak did not lead to data exfiltration?
- How would you automate this so the next rotation is one click?