Interview Prep/CI/CD/Release Engineering and Progressive Delivery

How do you do database schema migrations in Kubernetes deployments safely?

IntermediateProductionRelease Engineering and Progressive Delivery
Answer

Run the migration as a one-off Kubernetes Job or Helm pre-upgrade hook using the same image as the app, with backoffLimit small and a timeout, before the new pods roll out. Use the migration tool's locking (Flyway, Liquibase and Alembic use a lock table), so concurrent runs are safe. Do not run migrations in the app's startup path when you have many replicas. Keep migrations backward compatible so a failed rollout can roll back code alone.

All CI/CD questions Roadmap: CI/CD fundamentals

More on Release Engineering and Progressive Delivery