🎤Speaking at KubeCon EU 2026Lessons Learned Orchestrating Multi-Tenant GPUs on OpenShift AIView Session
Deployments beginner ⏱ 15 minutes K8s 1.28+

How to Perform Rolling Updates with Zero Downtime

Master Kubernetes rolling updates to deploy new application versions without service interruption. Learn update strategies, rollback procedures, and best practices.

By Luca Berton

The Problem

You need to update your application to a new version without causing downtime or disrupting active users.

The Solution

Use Kubernetes rolling update strategy to gradually replace old pods with new ones, ensuring continuous availability.

Understanding Rolling Updates

A rolling update incrementally replaces instances of the old version with the new version:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1        # Max pods above desired count
      maxUnavailable: 1  # Max pods that can be unavailable
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: myapp:v1.0.0
        ports:
        - containerPort: 8080
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5

Step 1: Deploy the Initial Version

Apply your deployment:

kubectl apply -f deployment.yaml

Verify the deployment:

kubectl get deployment myapp
kubectl get pods -l app=myapp

Step 2: Trigger a Rolling Update

Update the image version:

kubectl set image deployment/myapp myapp=myapp:v2.0.0

Or edit the deployment directly:

kubectl edit deployment myapp

Step 3: Monitor the Rollout

Watch the rollout progress:

kubectl rollout status deployment/myapp

View rollout history:

kubectl rollout history deployment/myapp

Step 4: Rollback if Needed

If something goes wrong, rollback to the previous version:

# Rollback to previous version
kubectl rollout undo deployment/myapp

# Rollback to specific revision
kubectl rollout undo deployment/myapp --to-revision=2

Best Practices

1. Always Use Readiness Probes

Readiness probes ensure traffic is only sent to healthy pods:

readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  initialDelaySeconds: 10
  periodSeconds: 5
  failureThreshold: 3

2. Set Resource Requests and Limits

resources:
  requests:
    memory: "128Mi"
    cpu: "100m"
  limits:
    memory: "256Mi"
    cpu: "500m"

3. Use Pod Disruption Budgets

Ensure minimum availability during updates:

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: myapp-pdb
spec:
  minAvailable: 2
  selector:
    matchLabels:
      app: myapp

Complete Example

Here’s a production-ready deployment with all best practices:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  annotations:
    kubernetes.io/change-cause: "Initial deployment v1.0.0"
spec:
  replicas: 4
  revisionHistoryLimit: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
        version: v1.0.0
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: myapp
        image: myapp:v1.0.0
        ports:
        - containerPort: 8080
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 5
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 10
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "500m"
        lifecycle:
          preStop:
            exec:
              command: ["/bin/sh", "-c", "sleep 10"]

Common Issues

Pods Stuck in Pending

Check resource availability and node capacity.

Rollout Taking Too Long

Review readiness probe configuration and increase failure thresholds.

Traffic Sent to Unhealthy Pods

Ensure readiness probes are properly configured with appropriate thresholds.

Key Takeaways

  • Rolling updates provide zero-downtime deployments
  • Always use readiness probes to control traffic routing
  • Keep revision history for easy rollbacks
  • Use PodDisruptionBudgets for high availability

📘 Go Further with Kubernetes Recipes

Love this recipe? There’s so much more! This is just one of 100+ hands-on recipes in our comprehensive Kubernetes Recipes book.

Inside the book, you’ll master:

  • ✅ Production-ready deployment strategies
  • ✅ Advanced networking and security patterns
  • ✅ Observability, monitoring, and troubleshooting
  • ✅ Real-world best practices from industry experts

“The practical, recipe-based approach made complex Kubernetes concepts finally click for me.”

👉 Get Your Copy Now — Start building production-grade Kubernetes skills today!

#deployment #rolling-update #zero-downtime #rollback #strategy

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.