Lesson  in  Kubelings — Learn Kubernetes the Rustlings Way

Fix the Rolling Update: unsafe maxSurge/maxUnavailable

A web Deployment ships every release with a full outage — its rollout strategy tears down all pods at once and never surges new ones. Fix the rolling update strategy so deploys stay available, then confirm the Deployment is healthy.

The situation

The web Deployment in the kubelings namespace serves production traffic, but every release causes a brief total outage. Its RollingUpdate strategy is set to maxSurge: 0 and maxUnavailable: 100% — so on each rollout Kubernetes is allowed to terminate all pods before any replacement is Ready, and is not allowed to surge a single extra pod to cover the gap.

 ┌───────────────────┐
 │old pods terminate │
 │                   │
 └───────────────────┘
          │           
 maxUnavailable 100%  
          │           
          ▼           
   ┌─────────────┐    
   │0 pods Ready │    
   │             │    
   └─────────────┘    
          │           
maxSurge 0, no cover  
          │           
          ▼           
   ┌───────────────┐  
   │new pods start │  
   │               │  
   └───────────────┘  

Your task

Make web's rolling update zero-downtime:

  1. Set maxSurge so at least one new pod can start before old ones go away.
  2. Set maxUnavailable so the whole fleet can't be taken down at once.
  3. Keep the Deployment Available (all 3 replicas Ready).
kubectl -n kubelings get deploy web -o yaml | less
Hint

Edit the strategy, e.g.:

kubectl -n kubelings patch deploy web --type=merge -p \
  '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":"25%"}}}}'

maxSurge ≥ 1 lets a replacement come up first; maxUnavailable < 100% keeps capacity during the roll.

Solution

Root cause

web's RollingUpdate strategy was maxSurge: 0 + maxUnavailable: 100%. That combination lets a rollout delete every pod at once (100% unavailable) while forbidding any extra pod from starting first (0 surge) — a guaranteed outage on every deploy.

Fix

kubectl -n kubelings patch deploy web --type=merge -p \
  '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":"25%"}}}}'

or kubectl -n kubelings edit deploy web and set:

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 1
    maxUnavailable: 25%

Verify

kubectl -n kubelings rollout status deploy/web
kubectl -n kubelings get deploy web \
  -o jsonpath='{.spec.strategy.rollingUpdate}{"\n"}'