DevDocs
⚙️ Kubernetes⭐ Featured

Kubernetes Deployment Strategies

Deep dive into Kubernetes deployment strategies — Rolling Updates, Blue/Green, Canary, and A/B deployments with real-world manifests and rollback procedures.

Satveek Gupta February 20, 2026 18 min read Updated May 10, 2026
kubernetes deployments rollout canary blue-green
Edit this page on GitHub

Overview

Kubernetes provides powerful primitives for zero-downtime deployments. Understanding deployment strategies is essential for maintaining high availability in production.

Strategy Comparison

StrategyDowntimeRiskRollback SpeedResource Cost
RecreateYesHighFastLow
Rolling UpdateNoneMediumMediumLow
Blue/GreenNoneLowInstant2x
CanaryNoneVery LowInstantMedium
A/B TestingNoneLowInstantMedium

Rolling Update (Default)

rolling-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  namespace: production
spec:
  replicas: 6
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 2        # Allow 2 extra pods during update
      maxUnavailable: 1  # At most 1 pod down at a time
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
        version: v2
    spec:
      containers:
        - name: web-app
          image: myapp:v2.1.0
          ports:
            - containerPort: 8080
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
            failureThreshold: 3
          livenessProbe:
            httpGet:
              path: /livez
              port: 8080
            initialDelaySeconds: 30
            periodSeconds: 10
          resources:
            requests:
              memory: "128Mi"
              cpu: "250m"
            limits:
              memory: "256Mi"
              cpu: "500m"
Warning

Always define readinessProbe. Without it, Kubernetes sends traffic to pods that aren't ready, causing 5xx errors during rollouts.

Blue/Green Deployment

Loading diagram…
blue-green.yaml
# Blue deployment (current production)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app-blue
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
      slot: blue
  template:
    metadata:
      labels:
        app: web-app
        slot: blue
        version: v1
    spec:
      containers:
        - name: web-app
          image: myapp:v1.0.0

---
# Green deployment (new version)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app-green
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
      slot: green
  template:
    metadata:
      labels:
        app: web-app
        slot: green
        version: v2
    spec:
      containers:
        - name: web-app
          image: myapp:v2.0.0

---
# Service — switch between blue/green by changing selector
apiVersion: v1
kind: Service
metadata:
  name: web-app-svc
spec:
  selector:
    app: web-app
    slot: green  # ← Change this to switch traffic
  ports:
    - port: 80
      targetPort: 8080

Switching Traffic

switch-traffic.sh
# Switch to green
kubectl patch service web-app-svc -p '{"spec":{"selector":{"slot":"green"}}}'

# Verify rollout
kubectl get pods -l slot=green

# If issues, instant rollback to blue
kubectl patch service web-app-svc -p '{"spec":{"selector":{"slot":"blue"}}}'

Canary Deployment

1

Deploy canary with 10% traffic

# Deploy canary (1 replica = 10% if main has 9)
kubectl apply -f canary-deployment.yaml
canary-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app-canary
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web-app
      track: canary
  template:
    metadata:
      labels:
        app: web-app
        track: canary
    spec:
      containers:
        - name: web-app
          image: myapp:v2.0.0-beta
2

Monitor metrics for 30 minutes

# Watch error rate
kubectl top pods -l app=web-app
kubectl logs -l track=canary --tail=100 -f
3

Promote to full rollout

# If metrics look good, promote
kubectl set image deployment/web-app-main web-app=myapp:v2.0.0-beta
kubectl delete deployment web-app-canary

Rollback

rollback.sh
# Check rollout history
kubectl rollout history deployment/web-app

# Rollback to previous version
kubectl rollout undo deployment/web-app

# Rollback to specific revision
kubectl rollout undo deployment/web-app --to-revision=3

# Check rollout status
kubectl rollout status deployment/web-app

References

PreviousTerraform AWS Infrastructure ModulesNextDocker Compose Production Guide