You must deploy a database migration that runs once before the new app version starts. How?
IntermediateScenarioDeployments and rollouts
Answer
Situation read → Each release needs a schema migration, and running it from every app pod would race.
What I'd do →
- Run the migration as a Job (or a Helm
pre-upgradehook) withbackoffLimitandactiveDeadlineSeconds - Use an expand-and-contract migration so the old version still works with the new schema
- Gate the Deployment update on Job completion in CI (
kubectl wait --for=condition=complete job/migrate --timeout=300s) - Avoid init containers for migrations, since every replica would run them
- Keep the migration idempotent and take a backup first
Why → A Job runs to completion exactly once, and backward-compatible migrations make rollbacks safe.
Interview tip → Interviewers like hearing "expand, deploy, contract" for zero-downtime schema changes.
More on Deployments and rollouts
You applied a new image tag and the rollout seems stuck at "1 out of 3 new replicas have been updated". What do you check first?BeginnerHow do you roll back a bad release and verify you are back on the previous version?BeginnerA rollout must never reduce capacity below current replicas. How do you configure the strategy?IntermediateYou need a blue/green deployment without a service mesh. How do you do it with plain Kubernetes?IntermediateHow would you do a canary release with only Deployments and a Service?IntermediateWhat is the difference between Recreate and RollingUpdate strategies and when would you pick Recreate?Beginner