DevOps Engineer interview question
How do you design CI/CD for a web service?
CI builds one immutable artifact and runs lint, tests, security and migration checks; CD promotes that same artifact through environments with approvals where needed, progressive rollout, health gates, observability and rollback.
Direct answer
What a strong answer covers
How it works
CI produces one immutable artifact per commit, a container image tagged with the commit SHA, after linting, unit and integration tests, dependency and secret scanning, and a check that database migrations are backward compatible. CD promotes that exact artifact, never a rebuild, through environments: automatic to staging with smoke tests, then to production with an approval where the risk warrants it, rolled out progressively with health gates on error rate and latency that pause or roll back automatically. Observability carries the version label so problems are attributable, and rollback is a promotion of the previous artifact, rehearsed regularly.
Example
A merge to main builds image api:abc123, runs the test suite against a PostgreSQL container, scans the image, and deploys to staging where a smoke test hits the health and login endpoints. A manual approval promotes the same image to production as a canary at 10 percent; the pipeline watches error rate and p95 for 15 minutes, then completes the rollout. A spike in 5xx during one canary paused the rollout and paged the on-call before customers noticed.
Common mistakes
- Rebuilding the image for production so what was tested is not what ships.
- Deploying to 100 percent at once with no health gate.
- Coupling a destructive migration to the deploy so rollback is impossible.
A useful answer structure
Answer from your own work.
Do not memorise a script: use only examples you can explain honestly in follow-up questions.
Open the desktop workspace and rehearse a clear answer in your own words.