Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav β€” full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with ❀️ & By - Anubhav

Β© 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 04 Β· Operations & SecurityChapter 25 of 33
24.
Phase 04Read time ~17 minDifficulty intermediate

Rolling Updates & Rollbacks πŸš€

Warrior, now we're entering production deployment territory.

In this chapter
  • 01The Deployment Problem
  • 02Rolling Update
  • 03Basic Architecture
  • 04Example
  • 05Watch the Rollout
  • 06What Is a ReplicaSet Doing?
  • 07RollingUpdate Strategy
  • 08What Is maxUnavailable?
  • 09What Is maxSurge?
  • 10Visualizing maxSurge + maxUnavailable
  • 11Why Readiness Probes Matter
  • 12A Production Deployment Example
  • 13Why maxUnavailable: 0 Can Be Useful
  • 14maxSurge Has a Cost
  • 15Percentage Values
  • 16Rolling Update Isn't Magic Zero Downtime
  • 17Graceful Shutdown
  • 18terminationGracePeriodSeconds
  • 19PreStop Hook
  • 20Connection Between Service and Rolling Update
  • 21Rollout History
  • 22Rollback
  • 23Rollback to a Specific Revision
  • 24Verify Rollback
  • 25What Happens to Old ReplicaSets?
  • 26revisionHistoryLimit
  • 27Blue-Green Deployment
  • 28Blue-Green Architecture
  • 29Blue-Green Advantage
  • 30Canary Deployment 🐀
  • 31Why Canary?
  • 32Rolling vs Blue-Green vs Canary
  • 33Canary With Kubernetes
  • 34The Database Migration Problem ⚠️
  • 35Backward-Compatible Database Migration
  • 36Step 1
  • 37Step 2
  • 38Step 3
  • 39Step 4
  • 40Step 5
  • 41Expand-and-Contract
  • 42Why This Matters With Kubernetes
  • 43Container Image Versioning
  • 44Deployment Workflow
  • 45Production Rollout Checklist
  • 46Example Production Deployment
  • 47Useful Rollout Commands
  • 48Start/update
  • 49Status
  • 50History
  • 51Specific revision
  • 52Undo
  • 53Undo to specific revision
  • 54Restart Pods
  • 55kubectl rollout restart vs undo
  • 56Restart
  • 57Undo
  • 58Pause and Resume Rollouts
  • 59Important Production Principle: Backward Compatibility
  • 60Interview Questions 🎯
  • 61Q1. What is a Rolling Update?
  • 62Q2. What is maxUnavailable?
  • 63Q3. What is maxSurge?
  • 64Q4. Why are readiness probes important during deployment?
  • 65Q5. How do you check rollout status?
  • 66Q6. How do you rollback?
  • 67Q7. How do you see rollout history?
  • 68Q8. Rolling vs Blue-Green?
  • 69Q9. What is Canary deployment?
  • 70Q10. Why can rolling deployments break database applications?
  • 71Q11. Why avoid latest in production?
  • 72Q12. Does RollingUpdate guarantee zero downtime?
  • 73Chapter 24 Cheat Sheet 🧠
  • 74Rolling Update
  • 75Important settings
  • 76Commands
  • 77Deployment strategies
  • 78Next β†’ Chapter 25: Helm β›΅
In this chapter (78 sections)
01The Deployment Problem02Rolling Update03Basic Architecture04Example05Watch the Rollout06What Is a ReplicaSet Doing?07RollingUpdate Strategy08What Is maxUnavailable?09What Is maxSurge?10Visualizing maxSurge + maxUnavailable11Why Readiness Probes Matter12A Production Deployment Example13Why maxUnavailable: 0 Can Be Useful14maxSurge Has a Cost15Percentage Values16Rolling Update Isn't Magic Zero Downtime17Graceful Shutdown18terminationGracePeriodSeconds19PreStop Hook20Connection Between Service and Rolling Update21Rollout History22Rollback23Rollback to a Specific Revision24Verify Rollback25What Happens to Old ReplicaSets?26revisionHistoryLimit27Blue-Green Deployment28Blue-Green Architecture29Blue-Green Advantage30Canary Deployment 🐀31Why Canary?32Rolling vs Blue-Green vs Canary33Canary With Kubernetes34The Database Migration Problem ⚠️35Backward-Compatible Database Migration36Step 137Step 238Step 339Step 440Step 541Expand-and-Contract42Why This Matters With Kubernetes43Container Image Versioning44Deployment Workflow45Production Rollout Checklist46Example Production Deployment47Useful Rollout Commands48Start/update49Status50History51Specific revision52Undo53Undo to specific revision54Restart Pods55kubectl rollout restart vs undo56Restart57Undo58Pause and Resume Rollouts59Important Production Principle: Backward Compatibility60Interview Questions 🎯61Q1. What is a Rolling Update?62Q2. What is maxUnavailable?63Q3. What is maxSurge?64Q4. Why are readiness probes important during deployment?65Q5. How do you check rollout status?66Q6. How do you rollback?67Q7. How do you see rollout history?68Q8. Rolling vs Blue-Green?69Q9. What is Canary deployment?70Q10. Why can rolling deployments break database applications?71Q11. Why avoid latest in production?72Q12. Does RollingUpdate guarantee zero downtime?73Chapter 24 Cheat Sheet 🧠74Rolling Update75Important settings76Commands77Deployment strategies78Next β†’ Chapter 25: Helm β›΅

So far we've learned how Kubernetes runs, scales, secures, monitors, and troubleshoots applications.

But there's a major production question:

How do I deploy version 2 of my application without taking version 1 offline?

That's what this chapter is about.


1. The Deployment Problem#

Suppose your current production application is:

node-api:v1

You want to deploy:

node-api:v2

A naive approach would be:

Stop v1
   ↓
Deploy v2
   ↓
Start v2

During this period:

Users
  ↓
❌ Application unavailable

This is downtime.

Kubernetes Deployments are designed to support controlled replacement of old Pods with new Pods.


2. Rolling Update#

A Rolling Update gradually replaces old Pods with new Pods.

Suppose you have:

3 replicas

Current:

v1  v1  v1

During the rollout:

v1  v1  v2

then:

v1  v2  v2

then:

v2  v2  v2

So users can continue receiving traffic while the new version is rolled out.


3. Basic Architecture#

Remember:

Deployment
    ↓
ReplicaSet
    ↓
Pods

When you update the image:

Deployment
     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     ↓              ↓
Old ReplicaSet   New ReplicaSet
     ↓              ↓
  v1 Pods         v2 Pods

The Deployment controls the transition.


4. Example#

Suppose your Deployment currently has:

spec:
  replicas: 3
 
  template:
    spec:
      containers:
        - name: node-api
          image: node-api:1.0

You release:

node-api:2.0

Change:

image: node-api:2.0

Then:

kubectl apply -f deployment.yaml

Kubernetes starts the rollout.


5. Watch the Rollout#

Run:

kubectl rollout status deployment/node-api

You might see:

Waiting for deployment "node-api" rollout to finish...
Waiting for deployment "node-api" rollout to finish...
deployment "node-api" successfully rolled out

You can also watch Pods:

kubectl get pods -w

-w means:

Watch for changes.

You might see:

node-api-v1-abc    Running
node-api-v1-def    Running
node-api-v1-ghi    Running
 
node-api-v2-xyz    ContainerCreating
 
node-api-v2-xyz    Running
 
node-api-v1-abc    Terminating

6. What Is a ReplicaSet Doing?#

Suppose initially:

Deployment
    ↓
ReplicaSet v1
    ↓
3 Pods

After updating:

Deployment
    β”‚
    β”œβ”€β”€ ReplicaSet v1
    β”‚      β”œβ”€β”€ Pod v1
    β”‚      β”œβ”€β”€ Pod v1
    β”‚      └── Pod v1
    β”‚
    └── ReplicaSet v2
           β”œβ”€β”€ Pod v2
           └── Pod v2

During the rollout, both ReplicaSets can temporarily exist.

Eventually:

Deployment
    ↓
ReplicaSet v2
    ↓
3 Pods

The old ReplicaSet is scaled down.


7. RollingUpdate Strategy#

A Deployment normally uses:

strategy:
  type: RollingUpdate

You can configure:

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

These two settings are extremely important.


8. What Is maxUnavailable?#

Suppose:

replicas = 3

and:

maxUnavailable: 1

This means Kubernetes can have at most approximately one fewer available replica than the desired count during the rollout, subject to Deployment rollout behavior.

So instead of allowing all 3 to disappear:

v1 v1 v1

Kubernetes maintains availability while replacing them.


9. What Is maxSurge?#

maxSurge controls how many Pods can temporarily exist above the desired replica count during the rollout.

Suppose:

replicas = 3
maxSurge = 1

Kubernetes can temporarily have:

4 Pods

For example:

v1
v1
v1
v2 ← new

Then eventually:

v1
v1
v2
v2

and finally:

v2
v2
v2

10. Visualizing maxSurge + maxUnavailable#

Suppose:

replicas = 3
maxSurge = 1
maxUnavailable = 1

A simplified rollout could look like:

START
 
v1  v1  v1

Create one extra v2:

v1  v1  v1  v2

Once the new Pod is ready, remove an old one:

v1  v1  v2

Create another v2:

v1  v1  v2  v2

Remove old:

v1  v2  v2

Create final:

v1  v2  v2  v2

Remove final old:

v2  v2  v2

The exact sequence depends on readiness, availability and rollout state, but this gives you the correct mental model.


11. Why Readiness Probes Matter#

This connects directly to Chapter 14.

Imagine new Pod starts:

v2

but the application isn't actually ready.

If Kubernetes immediately sends traffic to it:

Users
  ↓
v2
  ↓
❌ Failure

With a readiness probe:

v2 starts
   ↓
Readiness probe
   ↓
Not Ready
   ↓
No normal Service traffic

Once healthy:

Readiness = success
       ↓
Pod becomes Ready
       ↓
Service can route traffic

Therefore:

Readiness probes are a critical part of safe rolling deployments.


12. A Production Deployment Example#

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: node-api
 
spec:
  replicas: 3
 
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
 
  selector:
    matchLabels:
      app: node-api
 
  template:
    metadata:
      labels:
        app: node-api
 
    spec:
      containers:
        - name: node-api
          image: node-api:2.0
 
          ports:
            - containerPort: 3000
 
          readinessProbe:
            httpGet:
              path: /ready
              port: 3000
            periodSeconds: 5
 
          livenessProbe:
            httpGet:
              path: /health
              port: 3000
            periodSeconds: 10

This combines several concepts you've already learned:

Deployment
+
RollingUpdate
+
Replicas
+
Readiness
+
Liveness

13. Why maxUnavailable: 0 Can Be Useful#

For applications where you want all existing replicas to remain available during rollout:

maxUnavailable: 0

combined with:

maxSurge: 1

means Kubernetes can create extra capacity before removing old Pods.

For example:

3 desired
 
v1 v1 v1

Create:

v1 v1 v1 v2

Wait until v2 becomes Ready.

Then remove v1:

v1 v1 v2

And continue.

This can reduce availability risk, but it temporarily requires additional capacity.


14. maxSurge Has a Cost#

Suppose:

100 replicas

and:

maxSurge: 50

During rollout, you may temporarily need:

150 Pods

That means:

More CPU
More memory
More nodes potentially
More cost

So deployment configuration is a tradeoff between:

Availability
     ↕
Resource usage
     ↕
Deployment speed

15. Percentage Values#

You can use percentages.

Example:

maxUnavailable: 25%
maxSurge: 25%

For:

replicas = 20

approximately:

25% = 5 Pods

So the rollout can use a surge/unavailability budget based on the desired replica count.


16. Rolling Update Isn't Magic Zero Downtime#

This is an important interview point.

Someone might say:

"Kubernetes rolling updates guarantee zero downtime."

That's too strong.

Zero downtime depends on several things:

Enough replicas
+
Readiness probes
+
Healthy application
+
Correct Service
+
Correct rollout strategy
+
Sufficient cluster capacity
+
Backward-compatible changes
+
Proper termination behavior

For example:

3 replicas

but all three depend on one database migration that breaks the old version.

You can still have downtime.


17. Graceful Shutdown#

When Kubernetes terminates a Pod, your application should gracefully stop accepting new work and finish active requests when possible.

For Node.js:

process.on("SIGTERM", async () => {
  console.log("SIGTERM received");
 
  server.close(() => {
    console.log("HTTP server closed");
    process.exit(0);
  });
});

Conceptually:

Pod termination
      ↓
SIGTERM
      ↓
Node.js receives signal
      ↓
Stop accepting new requests
      ↓
Finish active requests
      ↓
Exit

This is very important for production deployments.


18. terminationGracePeriodSeconds#

Kubernetes gives a Pod a grace period for termination.

Example:

spec:
  terminationGracePeriodSeconds: 30

Conceptually:

SIGTERM
   ↓
Grace period
   ↓
Application shuts down

If the process doesn't terminate within the grace period, Kubernetes can eventually force termination.


19. PreStop Hook#

You can also configure a lifecycle hook:

lifecycle:
  preStop:
    exec:
      command:
        - /bin/sh
        - -c
        - "sleep 5"

But don't blindly add sleeps.

The goal should be:

Give your application and networking enough time to transition cleanly.

A real graceful-shutdown implementation is preferable to using arbitrary delays as a substitute for correct lifecycle handling.


20. Connection Between Service and Rolling Update#

Imagine:

Service
   β”‚
   β”œβ”€β”€ v1 Pod
   β”œβ”€β”€ v1 Pod
   └── v2 Pod

Service doesn't care that these are different versions.

It selects Pods using labels.

As Pods become Ready/unready:

Service endpoints
       ↓
Ready Pods

During a rollout:

v1 β†’ v2

the Service gradually sees the new Pods become available and old Pods disappear.


21. Rollout History#

Kubernetes keeps Deployment revision information.

Check:

kubectl rollout history deployment/node-api

Example:

deployment.apps/node-api
REVISION  CHANGE-CAUSE
1         <none>
2         <none>
3         <none>

You can inspect a revision:

kubectl rollout history deployment/node-api --revision=2

22. Rollback#

Suppose:

v1 β†’ v2

You deploy v2.

Everything looks fine.

Then users report:

Checkout broken

You can rollback:

kubectl rollout undo deployment/node-api

Kubernetes moves the Deployment back toward its previous revision.

Then:

kubectl rollout status deployment/node-api

23. Rollback to a Specific Revision#

You can specify:

kubectl rollout undo deployment/node-api --to-revision=2

Then:

kubectl rollout status deployment/node-api

24. Verify Rollback#

Don't just execute:

kubectl rollout undo deployment/node-api

Then assume everything is fixed.

Check:

kubectl get pods

Then:

kubectl rollout status deployment/node-api

Then:

kubectl logs <pod>

And ideally:

Error rate ↓
Latency normal
Pods Ready
Application functional

25. What Happens to Old ReplicaSets?#

Suppose:

Revision 1
Revision 2
Revision 3

Kubernetes can retain old ReplicaSets so that previous Deployment revisions can be rolled back.

You can see them:

kubectl get rs

Example:

node-api-abc123
node-api-def456
node-api-ghi789

The current ReplicaSet has active replicas; old ones can remain with zero replicas depending on revision history settings.


26. revisionHistoryLimit#

You can control how many old ReplicaSets are retained:

spec:
  revisionHistoryLimit: 10

This helps balance:

Rollback history
vs
Resource/object clutter

27. Blue-Green Deployment#

Rolling update isn't the only deployment strategy.

Another strategy is:

Blue-Green Deployment

Imagine:

Blue = v1
Green = v2

You run both versions simultaneously.

                Service
                   β”‚
                   ↓
              Blue v1

Then deploy:

Blue v1
Green v2

Test Green.

If everything is good, switch the Service:

                Service
                   β”‚
                   ↓
              Green v2

Now traffic goes to v2.


28. Blue-Green Architecture#

                 Internet
                    β”‚
                    ↓
                  Service
                    β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
             ↓             ↓
          Blue v1       Green v2

Initially:

Service β†’ Blue

After switch:

Service β†’ Green

29. Blue-Green Advantage#

The major advantage:

Very fast traffic switching and rollback.

If v2 is broken:

Service β†’ Blue v1

again.

But there is a cost:

v1 resources
+
v2 resources

You may temporarily need roughly double the application capacity.


30. Canary Deployment 🐀#

Another strategy:

Canary deployment

Instead of sending everyone to v2:

100% β†’ v1

you gradually expose v2:

95% β†’ v1
5%  β†’ v2

Then:

90% β†’ v1
10% β†’ v2

Then:

50% β†’ v1
50% β†’ v2

Eventually:

0% β†’ v1
100% β†’ v2

31. Why Canary?#

Suppose v2 has a bug affecting only certain requests.

With a normal rolling update, the new version may spread across the cluster.

With a canary:

Small traffic
    ↓
v2
    ↓
Monitor
    ↓
Errors?
Latency?
Business metrics?

If something goes wrong:

Stop rollout

and keep most users on v1.


32. Rolling vs Blue-Green vs Canary#

Strategy Idea Resource Usage Rollback
Rolling Gradually replace Pods Lower Relatively straightforward
Blue-Green Run both versions Higher Very fast
Canary Gradually shift traffic Variable Stop/shift traffic back

Don't think one strategy is universally "best."

The right choice depends on:

Application
Traffic
Risk
Cost
Infrastructure
Release frequency
Rollback requirements

33. Canary With Kubernetes#

Basic Kubernetes Deployment rolling updates aren't automatically equivalent to sophisticated percentage-based canary routing.

For advanced canary deployments, teams often use:

  • Ingress/controller traffic splitting
  • Service mesh
  • Argo Rollouts
  • cloud-specific deployment systems

For example:

Ingress
   β”‚
   β”œβ”€β”€ 95% β†’ v1
   β”‚
   └── 5%  β†’ v2

Then gradually change the split.


34. The Database Migration Problem ⚠️#

This is one of the most important production topics.

Suppose v1 expects:

users.name

You release v2 that expects:

users.first_name
users.last_name

You immediately change the database:

name β†’ first_name + last_name

Now:

v1 Pods
   ↓
❌ Can't find name

Even though you're doing a rolling deployment.


35. Backward-Compatible Database Migration#

A safer strategy is often:

Step 1#

Add new columns:

name
first_name
last_name

Both versions can work.

Step 2#

Deploy application version that understands both schemas.

Step 3#

Backfill data.

Step 4#

Move traffic fully to new version.

Step 5#

Only later remove old schema elements.

This is often called an expand-and-contract approach.


36. Expand-and-Contract#

Visualize:

OLD
 └── name
 
        ↓
 
EXPAND
 β”œβ”€β”€ name
 β”œβ”€β”€ first_name
 └── last_name
 
        ↓
 
NEW APP
Uses new fields
 
        ↓
 
CONTRACT
Remove old name

This makes rolling deployments safer because old and new application versions can coexist temporarily.


37. Why This Matters With Kubernetes#

During a rolling update:

v1 + v2

can coexist.

Therefore your database schema often needs to support:

v1
+
v2

simultaneously.

This is a fundamental production deployment principle.


38. Container Image Versioning#

Avoid relying on:

image: node-api:latest

for controlled production releases.

Prefer:

node-api:1.0.0
node-api:1.1.0
node-api:1.2.0

or immutable image digests:

node-api@sha256:...

Why?

Because:

v1.0.0

has a clear identity.

But:

latest

can change.


39. Deployment Workflow#

A realistic production workflow:

Developer
    ↓
Git commit
    ↓
CI pipeline
    ↓
Run tests
    ↓
Build Docker image
    ↓
Push image to registry
    ↓
Update Kubernetes manifest
    ↓
Deployment rollout
    ↓
New Pods
    ↓
Startup Probe
    ↓
Readiness Probe
    ↓
Service traffic
    ↓
Monitoring
    ↓
Success / Rollback

We'll go much deeper into CI/CD in Chapter 30.


40. Production Rollout Checklist#

Before deploying:

β˜‘ Image exists
β˜‘ Image version is immutable
β˜‘ Readiness probe works
β˜‘ Liveness probe works
β˜‘ Resources configured
β˜‘ Enough replicas
β˜‘ Cluster has capacity
β˜‘ Database migration is compatible
β˜‘ Configuration exists
β˜‘ Secrets exist
β˜‘ Monitoring exists
β˜‘ Rollback procedure known

41. Example Production Deployment#

Here's a stronger example:

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: node-api
 
spec:
  replicas: 3
 
  revisionHistoryLimit: 5
 
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
 
  selector:
    matchLabels:
      app: node-api
 
  template:
    metadata:
      labels:
        app: node-api
 
    spec:
      terminationGracePeriodSeconds: 30
 
      containers:
        - name: node-api
          image: registry.example.com/node-api:2.1.0
 
          ports:
            - name: http
              containerPort: 3000
 
          resources:
            requests:
              cpu: "250m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
 
          startupProbe:
            httpGet:
              path: /health
              port: 3000
            periodSeconds: 5
            failureThreshold: 12
 
          readinessProbe:
            httpGet:
              path: /ready
              port: 3000
            periodSeconds: 5
            failureThreshold: 3
 
          livenessProbe:
            httpGet:
              path: /health
              port: 3000
            periodSeconds: 10
            failureThreshold: 3

Notice how many previous chapters come together:

Deployment
Replicas
RollingUpdate
Resources
Startup Probe
Readiness
Liveness
Graceful termination
Versioned image

That's the point of the course: concepts start connecting together.


42. Useful Rollout Commands#

Start/update#

kubectl apply -f deployment.yaml

Status#

kubectl rollout status deployment/node-api

History#

kubectl rollout history deployment/node-api

Specific revision#

kubectl rollout history deployment/node-api --revision=2

Undo#

kubectl rollout undo deployment/node-api

Undo to specific revision#

kubectl rollout undo deployment/node-api --to-revision=2

Restart Pods#

kubectl rollout restart deployment/node-api

Important:

rollout restart restarts the Pods; it is not the same as rolling back to an older application version.


43. kubectl rollout restart vs undo#

Restart#

kubectl rollout restart deployment/node-api

Means:

Recreate the Pods using the current Deployment specification.

Undo#

kubectl rollout undo deployment/node-api

Means:

Revert the Deployment toward a previous revision.

Very common interview question.


44. Pause and Resume Rollouts#

You can pause:

kubectl rollout pause deployment/node-api

Then make changes.

Resume:

kubectl rollout resume deployment/node-api

This can be useful for controlled rollout workflows, though automated deployment systems often manage releases differently.


45. Important Production Principle: Backward Compatibility#

During deployments, you may have:

v1
v1
v2
v2

Therefore:

v1 and v2 may need to work simultaneously.

That applies to:

API contracts
Database schemas
Message formats
Cache formats
Events
Environment variables
External integrations

This is one of the biggest differences between:

"Works on my machine"

and:

"Safe production deployment"

46. Interview Questions 🎯#

Q1. What is a Rolling Update?#

A Deployment strategy that gradually replaces old Pods with new Pods while maintaining application availability according to the configured rollout constraints.


Q2. What is maxUnavailable?#

It controls how many desired replicas may be unavailable during a rolling update.


Q3. What is maxSurge?#

It controls how many additional Pods may temporarily be created above the desired replica count during a rolling update.


Q4. Why are readiness probes important during deployment?#

They prevent Pods that aren't ready from receiving normal Service traffic.


Q5. How do you check rollout status?#

kubectl rollout status deployment/<name>

Q6. How do you rollback?#

kubectl rollout undo deployment/<name>

Q7. How do you see rollout history?#

kubectl rollout history deployment/<name>

Q8. Rolling vs Blue-Green?#

Rolling:
Gradually replace Pods.
 
Blue-Green:
Run two environments and switch traffic.

Q9. What is Canary deployment?#

Gradually expose a new version to a subset of traffic/users before increasing its traffic share.


Q10. Why can rolling deployments break database applications?#

Because old and new application versions may run simultaneously and may expect incompatible database schemas.


Q11. Why avoid latest in production?#

Because it doesn't provide a stable, immutable version identity and can make deployments/reproduction/rollback less predictable.


Q12. Does RollingUpdate guarantee zero downtime?#

No. Availability depends on application design, readiness, replicas, capacity, traffic routing, graceful shutdown, compatible changes, and rollout configuration.


47. Chapter 24 Cheat Sheet 🧠#

Rolling Update#

v1 v1 v1
 ↓
v1 v1 v2
 ↓
v1 v2 v2
 ↓
v2 v2 v2

Important settings#

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

Commands#

kubectl rollout status deployment/app
 
kubectl rollout history deployment/app
 
kubectl rollout undo deployment/app
 
kubectl rollout undo deployment/app --to-revision=2
 
kubectl rollout restart deployment/app
 
kubectl get rs
 
kubectl get pods -w

Deployment strategies#

Rolling
   ↓
Gradual replacement
 
Blue-Green
   ↓
Two versions + traffic switch
 
Canary
   ↓
Small traffic β†’ new version β†’ gradually increase

πŸ”₯ The Most Important Mental Model#

A production deployment isn't simply:

Docker image β†’ Kubernetes

It's:

                 NEW VERSION
                      β”‚
                      ↓
                 Docker Image
                      β”‚
                      ↓
                 Deployment
                      β”‚
                      ↓
               New ReplicaSet
                      β”‚
                      ↓
                  New Pods
                      β”‚
                      ↓
               Startup Probe
                      β”‚
                      ↓
              Readiness Probe
                      β”‚
                      ↓
                  Service
                      β”‚
                      ↓
                   Users
                      β”‚
                      ↓
                 Monitoring
                      β”‚
                β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
                ↓           ↓
             Healthy      Failure
                ↓           ↓
             Continue     Rollback

And the most important production rule is:

A deployment is successful only when the new version is healthyβ€”not merely when the new Pods are created.


🎯 Chapter 24 Summary#

You now know:

  • Rolling Updates
  • ReplicaSets during rollout
  • maxUnavailable
  • maxSurge
  • Readiness during deployment
  • Graceful shutdown
  • Rollout history
  • Rollbacks
  • Blue-Green deployments
  • Canary deployments
  • Database migration compatibility
  • Image versioning
  • Production rollout workflow

Next β†’ Chapter 25: Helm β›΅#

This is where Kubernetes YAML starts becoming much more manageable.

We'll learn:

  • Why Kubernetes YAML becomes difficult at scale
  • What Helm is
  • Helm Charts
  • Chart.yaml
  • values.yaml
  • Templates
  • helm install
  • helm upgrade
  • helm rollback
  • Helm releases
  • Variables
  • if conditions
  • Loops
  • Reusable Kubernetes templates
  • Creating a Helm Chart for your Node.js + Next.js application
  • Helm vs raw YAML
  • Helm vs Kustomize
  • Production Helm best practices

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 23 β€” Kubernetes Troubleshooting πŸ”§Next ChapterChapter 25 β€” Helm β›΅
PrevNext