Kubernetes Deployment Strategies: Rolling, Blue-Green, and Canary

Jirayu Saengwannakool

Jirayu Saengwannakool

· 10 min read
Kubernetes deployment strategies comparison

Choosing the right deployment strategy is crucial for maintaining high availability while shipping new features. Let's explore the main strategies available in Kubernetes.

Rolling Deployments

The default Kubernetes strategy. Gradually replaces old pods with new ones:

  • Pros: Simple, resource-efficient, automatic rollback
  • Cons: Slower rollout, version mixing during deployment
  • Use when: Standard updates with backward compatibility

Blue-Green Deployments

Maintains two identical environments. Switch traffic all at once:

  • Pros: Instant rollback, easy testing, no version mixing
  • Cons: Requires double resources, database migration challenges
  • Use when: Critical updates requiring instant rollback capability

Canary Deployments

Gradually shift traffic to new version while monitoring metrics:

  • Pros: Risk mitigation, real-world testing, gradual rollout
  • Cons: Complex setup, requires monitoring, longer deployment time
  • Use when: High-risk changes or testing new features with real users

Implementation Example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    spec:
      containers:
      - name: app
        image: myapp:v2

Best Practices

  1. Always implement health checks (readiness and liveness probes)
  2. Monitor metrics during deployments
  3. Automate rollback based on error rates
  4. Test in staging with same strategy
  5. Document rollback procedures

Share this article

Related Posts

← Back to all posts