QA
Intermediate LevelDocker & Deployment

How do Canary Deployments route weighted traffic using NGINX Ingress Controller?

❓ Interview Prompt: Explain Canary deployment traffic splitting, NGINX Ingress canary annotations, and progressive rollout strategies for risk mitigation.

Canary Deployment releases a new version to a small percentage of real users (the "canaries") while the majority continues on the stable version. This allows monitoring error rates and performance before full rollout.

Traffic Splitting Strategies:

1
Weight-based: 5% → canary, 95% → stable (random user selection).
2
Header-based: Users with X-Canary: true header go to canary.
3
Cookie-based: Sticky routing — once a user gets the canary, they stay on it.

Progressive Rollout:

5% → 25% → 50% → 100% — gradually increase canary weight while monitoring:

•
Error rate (must stay below baseline).
•
P99 latency (must not degrade).
•
Business metrics (conversion rates, etc.).

Kubernetes NGINX Ingress Canary Annotations:

NGINX Ingress Controller natively supports canary deployments via annotations — no service mesh required.

Code Implementation Example

yaml
# Stable Ingress (v1 — 95% of traffic)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: api-stable
spec:
  rules:
    - host: api.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: api-v1-svc
                port:
                  number: 80
---
# Canary Ingress (v2 — 5% of traffic)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: api-canary
  annotations:
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "5"   # 5% to canary
    # nginx.ingress.kubernetes.io/canary-by-header: "X-Canary"  # header-based
spec:
  rules:
    - host: api.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: api-v2-svc
                port:
                  number: 80
💡NGINX Ingress canary-weight annotation routes 5% of traffic to v2 — increase weight progressively after validation.
🎯 Interview Key Takeaway

Canary deployments expose new versions to a small traffic percentage (5%) first — progressive rollout from 5→25→50→100% minimizes blast radius of bugs.

#Canary#NGINX Ingress#Traffic Splitting#Zero-Risk Rollout#Kubernetes#Intermediate
Back to all Docker & Deployment Questions→

More Docker & Deployment Interview Questions

Beginner LevelDocker & Deployment

How do Docker Multi-Stage Builds minimize image size and improve security?

Beginner LevelDocker & Deployment

What is the difference between a Docker Container and a Virtual Machine (VM)?

Beginner LevelDocker & Deployment

What is the difference between a Docker Image and a Docker Container?