Overview and What You Will Learn
Blue-green and canary are the two standard zero-downtime release strategies. Blue-green runs the new version next to the old one and switches all traffic at once after you have tested it. Canary sends the new version a small, growing share of real traffic and lets metrics decide whether to continue. Both give you a fast, automatic way back when a release is bad.
In this lab you will:
- Choose between blue-green and canary for a given service.
- Install Argo Rollouts and convert a Deployment into a Rollout.
- Split traffic with Istio so the canary gets an exact percentage.
- Gate each step with a Prometheus analysis that fails closed.
- Trigger a rollout from CI without stored cloud keys.
- Prove automatic rollback works before you trust it in production.
- Run the same service as a blue-green release with a preview environment.
Why This Matters in Production
A rolling update sends full production traffic to a new pod as soon as its readiness probe passes, and a readiness probe only proves the process is running, not that the code is correct. For a payments or checkout path, such as the traffic Razorpay or Stripe handle, a subtle bug can fail thousands of requests before anyone is paged.
Canary bounds that damage to a small, known slice of traffic for a known short window. Blue-green lets you smoke-test the whole new version with zero customer traffic, then switch with an instant way back. Teams at companies like Netflix and Spotify rely on this kind of progressive delivery so that releasing is routine, not an event.
Common MistakeCalling a release "canary" when it jumps from 5 to 100 percent with one manual click and no metric check in between. Without an automated gate it is just a slower rolling update. The value is the analysis deciding whether to proceed.
Core Principles
Blue-green and canary compared
| Strategy | Best when | Trade-off |
|---|---|---|
| Blue-green | You need a full preview and instant switch | Double capacity during cutover |
| Canary | You want real-traffic evidence in small steps | Needs good metrics and traffic routing |
Blue-green keeps two full versions side by side. Blue is live and green is the new version, idle until tested. A switch moves every request to green at once, and rollback is switching back, which is fast because blue never stopped running.
Canary exposes the new version gradually and checks metrics between steps. Each step either sets a traffic weight, pauses, or runs an analysis. A failed analysis aborts the rollout and returns all traffic to the stable version.
Exact percentages need a traffic router. Without Istio, NGINX Ingress, or a similar integration, Argo Rollouts approximates the weight by scaling replica counts. With 10 replicas, a 5 percent step rounds up to one pod, which is 10 percent. For precise low percentages use a router.
Database changes must work for both versions. Both versions talk to the same database during the rollout, so use expand and contract migrations: add new columns first, deploy, and remove old ones in a later release.
Feature flags are an alternative for logic risk. When the risk is in application behaviour rather than infrastructure, a flag service can expose a code path to a percentage of users with no traffic splitting, and rolling back means flipping the flag.
TipScope analysis queries to the canary service only. A canary at 5 percent can be failing badly while the aggregate error rate, dominated by stable traffic, still looks fine.
Detailed Step-by-Step Practical Lab
This lab releases an order-gateway service in the mumbai-prod-cluster using Argo Rollouts and Istio, with a Prometheus error-rate gate.
Milestone 1 - Install Argo Rollouts and the kubectl plugin
export ARGO_ROLLOUTS_VERSION=v1.7.2 kubectl create namespace argo-rolloutskubectl apply -n argo-rollouts \ -f https://github.com/argoproj/argo-rollouts/releases/download/${ARGO_ROLLOUTS_VERSION}/install.yaml # Install the plugincurl -LO https://github.com/argoproj/argo-rollouts/releases/download/${ARGO_ROLLOUTS_VERSION}/kubectl-argo-rollouts-linux-amd64chmod +x kubectl-argo-rollouts-linux-amd64sudo mv kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rolloutskubectl argo rollouts versionThe controller is running, but no Rollout exists yet.
Milestone 2 - Create stable and canary Services and an Istio VirtualService
apiVersion: v1kind: Servicemetadata: name: order-gateway-stable namespace: ordersspec: selector: app: order-gateway ports: - port: 80 targetPort: 8080apiVersion: v1kind: Servicemetadata: name: order-gateway-canary namespace: ordersspec: selector: app: order-gateway ports: - port: 80 targetPort: 8080apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata: name: order-gateway-vs namespace: ordersspec: hosts: - order-gateway.orders.svc.cluster.local http: - name: primary route: - destination: host: order-gateway-stable weight: 100 - destination: host: order-gateway-canary weight: 0Argo Rollouts will edit the two weights for you and add the right pod-hash selectors to each Service.
Milestone 3 - Define the AnalysisTemplate
apiVersion: argoproj.io/v1alpha1kind: AnalysisTemplatemetadata: name: canary-error-rate namespace: ordersspec: args: - name: canary-service metrics: - name: error-rate interval: 1m count: 5 failureLimit: 1 # fail closed: no data means we cannot judge, so it fails successCondition: len(result) > 0 && result[0] < 0.01 provider: prometheus: address: http://prometheus.monitoring:9090 query: | ( sum(rate(istio_requests_total{reporter="destination",destination_service_name="{{args.canary-service}}",response_code=~"5.."}[2m])) or vector(0) ) / sum(rate(istio_requests_total{reporter="destination",destination_service_name="{{args.canary-service}}"}[2m]))The or vector(0) matters. If the canary has no 5xx errors at all, the numerator has no series and the whole division returns nothing, which would fail a perfectly healthy canary. If there is no traffic at all, the denominator is empty, the result is empty, and the step correctly fails because the canary cannot be judged.
Milestone 4 - Create the canary Rollout
apiVersion: argoproj.io/v1alpha1kind: Rolloutmetadata: name: order-gateway namespace: ordersspec: replicas: 10 selector: matchLabels: app: order-gateway template: metadata: labels: app: order-gateway spec: containers: - name: order-gateway image: 418773912004.dkr.ecr.ap-south-1.amazonaws.com/order-gateway:v1.4.0 ports: - containerPort: 8080 strategy: canary: stableService: order-gateway-stable canaryService: order-gateway-canary trafficRouting: istio: virtualService: name: order-gateway-vs routes: - primary steps: - setWeight: 5 - pause: {duration: 2m} - analysis: templates: - templateName: canary-error-rate args: - name: canary-service value: order-gateway-canary - setWeight: 25 - pause: {duration: 5m} - analysis: templates: - templateName: canary-error-rate args: - name: canary-service value: order-gateway-canary - setWeight: 50 - pause: {} # wait here for a human to approve - setWeight: 100kubectl apply -f order-gateway-rollout.yamlkubectl argo rollouts get rollout order-gateway -n orders --watchA new image now starts a canary instead of a rolling update.
Milestone 5 - Trigger the rollout from CI without stored keys
In a GitOps setup, CI opens a pull request that bumps the image in the config repo and ArgoCD applies it. For a direct pipeline, authenticate with OIDC and set the image:
permissions: id-token: write contents: read jobs: release: runs-on: ubuntu-latest steps: - uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::418773912004:role/github-orders-deploy aws-region: ap-south-1 - run: aws eks update-kubeconfig --name mumbai-prod-cluster --region ap-south-1 - name: Start canary rollout run: | kubectl argo rollouts set image order-gateway \ order-gateway=418773912004.dkr.ecr.ap-south-1.amazonaws.com/order-gateway:${{ github.sha }} \ -n ordersThe watch command should now show the weight moving to 5 percent and pausing.
Milestone 6 - Prove automatic rollback
Deploy a build that deliberately returns HTTP 500 on a small share of requests, then watch the rollout.
kubectl argo rollouts get rollout order-gateway -n orderskubectl get analysisrun -n orderskubectl describe analysisrun <name> -n ordersThe status should become Degraded, the canary weight should return to 0, and the stable version should still serve all traffic. Do this in staging before you trust the gate in production.
Milestone 7 - Approve and promote a healthy canary
kubectl argo rollouts promote order-gateway -n orderskubectl argo rollouts get rollout order-gateway -n orders --watchPromote resumes the indefinite pause at 50 percent and the rollout completes at 100 percent.
Milestone 8 - Run the same service as blue-green
strategy: blueGreen: activeService: order-gateway-active previewService: order-gateway-preview autoPromotionEnabled: false scaleDownDelaySeconds: 600 # keep the old version warm for rollback prePromotionAnalysis: templates: - templateName: preview-smoke-checkThe new version is reachable at the preview Service while the active Service still serves users. After checks pass, kubectl argo rollouts promote order-gateway switches the active Service, and the old ReplicaSet stays up for ten minutes in case you need to go back.
Remember
pause: {}with no duration waits forever for a human. Decide deliberately which steps are automated and which are manual approvals.
SecurityBlue-green keeps the old version running during cutover. Apply the same network policies and secret access to both versions, not just whichever one the live Service points at.
Production Best Practices & Common Pitfalls
- Start the first canary step at 5 percent or lower so any damage is small.
- Scope every analysis query to the canary service or pods, not the whole service.
- Make analysis fail closed, and test it against both a healthy and a broken build.
- Use expand and contract database migrations so both versions work against the same schema.
- In blue-green, keep the old version warm for a defined rollback window before scaling it down.
- Alert on rollouts stuck in Paused longer than expected, which usually means a forgotten approval.
- Pin the Argo Rollouts version and upgrade it deliberately, like any other cluster controller.
Quick Reference & Troubleshooting Commands
| Symptom | Command | What to look for |
|---|---|---|
| Rollout stuck at a step | kubectl argo rollouts get rollout order-gateway -n orders |
A manual pause waiting for promote |
| Analysis always fails | kubectl describe analysisrun <name> -n orders |
Query returns no data or wrong labels |
| Traffic not split as expected | kubectl get virtualservice order-gateway-vs -n orders -o yaml |
Weights not matching the current step |
| Blue-green did not switch | kubectl get svc order-gateway-active -n orders -o yaml |
Selector still on the old ReplicaSet |
| Need to stop a bad release | kubectl argo rollouts abort order-gateway -n orders |
Weight returns to 0, status Degraded |