What is the difference between blue-green, rolling, and canary deployments?
CI/CD & GitOps · Basic level
Answer
Rolling deployment replaces instances gradually in the same environment. Blue-green creates a full new environment and switches traffic after validation. Canary deploys to a small subset first and expands based on metrics. Canary gives the most controlled exposure, while blue-green gives fast cutover and rollback.
Technical explanation
Traffic shifting should be separate from artifact build so the same artifact can be promoted or rolled back.
Use readiness checks, error budgets, and automated metrics before increasing production exposure.
CI/CD should optimize both speed and safety: fast feedback for developers, controlled promotion for environments, and clear evidence for operations.
The deployable artifact should be built once, versioned, scanned, and promoted by immutable version or digest rather than rebuilt per environment.
Use automated gates for tests, policy, security, and health checks; use human approval only for risk decisions that automation cannot make reliably.
Track delivery health with lead time, deployment frequency, change-failure rate, MTTR, pipeline duration, queue time, and flaky failure rate.
Hands-on example
1. Create or update a Jenkinsfile for the scenario: What is the difference between blue-green, rolling, and canary deployments.
2. Use a Declarative Pipeline skeleton: pipeline { agent { label 'linux && docker' } options { timestamps(); disableConcurrentBuilds() } stages { stage('Checkout') { steps { checkout scm } } stage('Test') { parallel { stage('Unit') { steps { sh 'make unit' } } stage('Lint') { steps { sh 'make lint' } } } } } post { always { junit 'reports/*.xml'; cleanWs() } failure { echo 'notify team' } } }.
3. Deploy the new artifact beside the old version, run smoke checks, shift 5% traffic, evaluate error rate and p95 latency for 10 minutes, then either increase traffic or rollback to the previous digest.
4. Publish the immutable result: tag the image with the Git SHA, push to ECR/Nexus, archive test reports, and record build URL, commit SHA, artifact digest, approver, and deployment status.
5. Prove the design by rerunning the same commit twice: the second run should reuse safe caches, produce the same artifact version or detect it already exists, and avoid duplicate side effects.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More CI/CD & GitOps interview questions
- How do you implement blue-green or canary deployment from a pipeline?
- How would you implement automatic rollback if a deployment is unhealthy?
- How do you keep a pipeline idempotent and safely re-runnable?
- What metrics define a healthy CI/CD system (lead time, deployment frequency, change-fail rate, MTTR)?
- What is the difference between archiving artifacts and publishing to a registry?
- What are the DORA metrics, and how have you used them?
- How do you handle build artifacts and where do you store them (Nexus, ECR)?
- What is GitOps, and what are its core principles?