Interview Prep/Real-World Interview/Kubernetes cluster-level

You rotated a database password in a Kubernetes Secret, but pods keep using the old one and auth errors start once the old password is revoked.

IntermediateTroubleshootingKubernetes cluster-level
Answer

Likely causes → Secrets used as environment variables are read only when the container starts. Mounted Secret volumes do update (after a kubelet sync delay), but not when mounted with subPath, and many apps read the file once at startup anyway.

Diagnose →

kubectl get deploy api -o jsonpath='{.spec.template.spec.containers[0].env}' | jq '.[] | select(.valueFrom.secretKeyRef)'
kubectl exec deploy/api -- printenv DB_PASSWORD | sha256sum
kubectl get secret db -o jsonpath='{.data.password}' | base64 -d | sha256sum

Fix → Roll the pods so they pick up the new value: kubectl rollout restart deploy/api.

Prevent → Rotate in two phases (add new credential, roll pods, then revoke old). Automate restarts on Secret change with a checksum annotation in the Helm template or a controller like Stakater Reloader, or have the app reload credentials from a mounted file or Secrets Manager.

All Real-World Interview questions Roadmap: Interview readiness

More on Kubernetes cluster-level