Rolling Updates in Kubernetes: Changing the Engine While the Car Keeps Moving

Rolling Updates in Kubernetes: Changing the Engine While the Car Keeps Moving

A beginner-friendly guide to how Kubernetes replaces the old version of your application with a new one, a few copies at a time, so that users keep being served throughout.

Imagine a busy restaurant with four waiters. The manager has bought new uniforms and trained everyone on a new ordering system. She could close the restaurant for the afternoon, retrain all four waiters at once and reopen in the evening. Customers would be angry, and the takings for the day would be lost. A smarter manager does it gently. She takes one waiter aside for training while the other three keep serving. When the first waiter returns, the second one goes for training, then the third, then the fourth. At no point is the restaurant closed, and by the evening, everyone is on the new system.

A rolling update in Kubernetes is that smarter manager. Your application runs as several identical copies, called Pods. When you release a new version, Kubernetes does not switch every copy off and on again. It replaces them gradually, a few at a time, always keeping enough healthy copies alive to serve your users. In this guide you will learn what a rolling update is, how it decides the pace, what can go wrong, how to undo a bad release, and how to design your application so that updates are boring and safe. Boring, in operations, is the highest compliment.

1The Problem: Releasing Without Disappointing Users

Before learning the tool, it helps to feel the problem that the tool removes.

Software never stops changing

A living application changes all the time. Developers fix bugs, add features, patch security holes and update libraries. In a modern team, a new version may be released many times a week, or even many times a day. Each release means that the copies of your application running in the cluster must be replaced by copies of the new version.

The naive way: stop everything, then start everything

The simplest method is to stop all the old copies and start all the new ones. This is easy to understand, but it has a serious cost: for the period between the last old copy stopping and the first new copy becoming ready, nobody is serving your users. For a hobby project, a few seconds of silence may not matter. For an online shop, a hospital system or a bank, even a short outage is unacceptable, and a long one can be very expensive.

Simple Analogy

Imagine a railway that repaints its carriages. Cancelling every train for a week and repainting them all would strand thousands of passengers. Instead, the railway repaints one carriage at a time while the rest of the fleet keeps running. Passengers hardly notice, and yet, after some weeks, the whole fleet has changed colour.

The second problem: releases go wrong

Even carefully tested code can misbehave in the real world. A new version may crash under real traffic, run out of memory, or fail to connect to a database. If all copies were replaced at once, the mistake would hit every user instantly. A gradual replacement limits the damage: if the first new copies look unhealthy, the release can be paused or reversed while most users are still being served by the old, working version.

!
Common Misconception

Many beginners think an update is a single instant event. In reality it is a process that takes time, during which old and new versions run side by side. Understanding that overlap is the key to doing updates safely.

Gradual
a few copies replaced at a time
No gap
enough healthy copies stay in service
Reversible
a bad release can be rolled back

2What Is a Rolling Update?

A rolling update is the default way Kubernetes replaces old Pods with new ones, gradually and safely.

The plain definition

A rolling update is an update strategy in which Kubernetes creates Pods of the new version and removes Pods of the old version in small steps, until all Pods run the new version. During the process, the application stays available, because at every moment a sufficient number of Pods is ready to serve requests.

You state what you want, for example “run this new image version”, and Kubernetes works out the careful sequence of steps by itself. You do not have to tell it which Pod to remove first or when to start the next one.

Simple Analogy

It is like changing the tyres of a bus fleet overnight, one bus at a time. There is always a bus on the route, and by morning every bus has fresh tyres. Nobody had to cancel the timetable.

Where it is used

Rolling updates are the default for Deployments, which are the most common way to run stateless applications in Kubernetes. Similar gradual behaviour is available for StatefulSets and DaemonSets, with rules suited to their own needs. Nearly every team that runs a web service, an interface for other programs or a background worker on Kubernetes uses rolling updates every day.

What it needs from you

Need 1

Several copies

With only one copy, there is nothing to keep serving while it is replaced. A rolling update shines when you run at least two or three.

Need 2

A truthful readiness check

Kubernetes must be able to tell when a new copy is truly ready to serve, or it may send traffic to a copy that is still starting.

Need 3

Compatible versions

Old and new versions run at the same time for a while, so they must be able to coexist, sharing the same database and messages.

Need 4

Room in the cluster

A rolling update often needs a little extra capacity, since new copies start before old ones stop.

i
Remember This

A rolling update does not test your code. It only controls how the new code is introduced. Good testing before the release, and good health checks during it, are what make a rolling update truly safe.

3Update Strategies Compared

A rolling update is one of several ways to release software. Knowing the others shows when each fits.

Strategy 1

Rolling update

Replaces copies gradually. Built into Deployments and used by default. Old and new versions coexist for a while.

Strategy 2

Recreate

Stops all old copies first and then starts all new ones. Causes a short outage, but guarantees that two versions never run together.

Strategy 3

Blue and green

Runs a complete second copy of the application, tests it and then switches all traffic at once. Needs double capacity for a while.

Strategy 4

Canary

Sends a small share of real users to the new version first, watches the results and only then widens the release.

QuestionRolling updateRecreateBlue and greenCanary
DowntimeNone if configured wellYes, a short gapNoneNone
Two versions at onceYes, brieflyNeverYes, but traffic goes to oneYes, with a split of traffic
Extra capacity neededA littleNoneA full second copyA little
Speed of rollbackFast, but gradualNeeds another restartInstant, by switching backFast, by removing the canary
Built into KubernetesYesYesBy combining objectsBy combining objects or add-on tools
Best forMost everyday releasesPrograms that cannot run two versions togetherHigh-stakes releases needing instant switch backRisky changes tested on real users
Simple Analogy

Rolling is repainting the fleet one carriage at a time. Recreate is stopping the whole railway for a week. Blue and green is building an entire second train, testing it and swapping tracks. Canary is letting a few brave passengers ride the new train first and asking how it went.

i
Good to Know

These strategies are not rivals. Many teams use rolling updates for ordinary releases and add a canary step for risky ones. Choose by the cost of failure and the ability of your application to coexist with its previous version.

4Where Rolling Updates Fit in the Architecture

To understand the process, you need a quick picture of the cluster around it.

The main players

A rolling update involves several parts of Kubernetes working together. None of them controls the whole process. Each reacts to what it sees, and the result is a smooth rollout.

Component 1

Deployment

The object that describes your application and how it should be updated. It is the one you edit when releasing a new version.

Component 2

ReplicaSet

A helper object created by the Deployment for each version. It keeps the right number of Pods of that one version running.

Component 3

Deployment controller

The background worker that compares the desired and actual state, creates the new ReplicaSet and shifts Pods between old and new.

Component 4

Scheduler

Places each new Pod on a machine with enough room.

Component 5

Kubelet

Starts and stops containers on each machine and runs the health checks that report readiness.

Component 6

Service

The steady front door for users. It sends traffic only to Pods that are ready, which is what keeps the update invisible.

flowchart TD
  U["Operator changes the image version"] --> D["Deployment"]
  D --> C["Deployment controller"]
  C --> N["New ReplicaSet for new version"]
  C --> O["Old ReplicaSet for old version"]
  N -->|"scale up gradually"| PN["New Pods"]
  O -->|"scale down gradually"| PO["Old Pods"]
  PN --> S["Service"]
  PO --> S
  S --> USERS["Users keep being served"]
        
FIG 1 — Two ReplicaSets trade Pods while the Service keeps serving users

Read the picture from the top. You change the Deployment. The controller creates a second ReplicaSet for the new version and then slowly grows it while shrinking the old one. The Service sits in front of both, sending users only to Pods that are ready. From the users’ point of view, nothing happens. From the cluster’s point of view, a careful hand-over is in progress.

Simple Analogy

It is a relay race in reverse. The old team runs, and as each new runner is ready and warmed up, one old runner steps out. The track is never empty, and the baton, which is the user’s request, is always in someone’s hand.

5What Triggers a Rolling Update?

Not every change causes a rollout. Knowing exactly what does saves both surprise and confusion.

The rule: the Pod template changed

A Deployment contains a blueprint for its Pods, called the Pod template. A rolling update starts when, and only when, this template changes. The template includes the container image, its version tag, environment settings, resource requests and limits, health check settings, labels and notes on the Pod, the start command and the list of attached volumes.

Changes that trigger a rollout

  • A new container image or a new version tag
  • Changed environment settings inside the template
  • New resource requests or limits
  • Changed health check settings
  • New labels or notes on the Pod template
  • A changed start command or added volume
  • A deliberate restart request, which adds a timestamp note to the template

Changes that do not trigger a rollout

  • Changing only the number of replicas
  • Changing labels or notes on the Deployment object itself, outside the template
  • Editing the contents of a settings bundle that Pods already use
  • Changing the contents of a secret bundle that Pods already use
  • Pushing a new image under the same version tag
  • Changing the update strategy settings alone

Two classic traps

The unchanged settings bundle

You edit a settings bundle and expect your application to change behaviour. But the Pod template did not change, so no rollout starts, and the running Pods keep their old settings. To roll out new settings, either restart the Deployment, or give the bundle a new name or a content fingerprint so that the template changes.

The reused image tag

You push a new image with the same tag as before, such as the tag latest, and nothing happens, because the Deployment definition still reads the same. Even if Pods restart later, different machines may hold different cached copies of that tag. Always give each release a unique, immutable tag, or refer to the image by its content digest.

Simple Analogy

Think of a recipe card pinned in a kitchen. The chefs only start cooking a new dish when the card changes. If you quietly swap the ingredients in the fridge but leave the card untouched, nobody notices, and the old dish is still served.

!
Common Mistake

Relying on the tag latest for production releases. It hides which version is running, makes rollbacks meaningless, and can cause different Pods of the same Deployment to run different code.

6The Two Dials: Max Surge and Max Unavailable

Two simple settings decide how fast and how carefully a rolling update moves.

Max surge

Max surge is how many extra Pods, beyond the desired number, may exist during the update. It lets Kubernetes start new copies before it removes old ones. A larger surge means faster updates, but needs more spare room in the cluster.

Max unavailable

Max unavailable is how many Pods may be missing from the desired number during the update. It lets Kubernetes remove old copies before every new one is ready. A larger value means faster updates, but leaves fewer Pods to serve users at any moment.

Simple Analogy

Back at the restaurant: max surge is how many extra temporary waiters the manager may call in during retraining. Max unavailable is how many waiters she may take away for training at the same time. Bring in more temps and you can retrain faster without ever being short-handed, but it costs more.

The defaults and how the numbers work

By default, both settings are twenty-five percent. Each may be given as a whole number or as a percentage of the desired replica count. Percentages are rounded: the surge is rounded up and the unavailable count is rounded down. The two may not both be zero, because then the update could never move.

Setting combinationWhat happensGood for
Surge 1, unavailable 0One new copy is started and must be ready before an old one is removedZero-downtime updates with a little spare room
Surge 0, unavailable 1An old copy is removed first, then a new one is started in its placeClusters with no spare room
Surge 25 percent, unavailable 25 percentBalanced default, some extra and some missingGeneral everyday use
Large surge, unavailable 0Many new copies start together, no old one is removed until replacements are readyFast, safe updates when capacity is plentiful
Large unavailable, surge 0Many old copies removed at once, capacity dipsTest environments where speed matters more than service

A worked example with four copies

Suppose the Deployment wants four copies, and both settings use the default twenty-five percent. A quarter of four is one, so at most one extra Pod may exist and at most one may be missing. That means the total number of Pods never exceeds five, and at least three are always available. The table below shows a typical, simplified sequence. Real updates move in small overlapping steps depending on how quickly Pods become ready.

MomentOld version PodsNew version PodsRule being respected
Start40All four serve users
Early31 startingAt least three old ones are ready
Midway22Total stays within four plus one extra
Late13Only ready Pods receive traffic
Finished04All four run the new version
i
Practical Tip

For anything important, set max unavailable to zero and keep a small surge. The update is a little slower and needs a little spare room, but capacity never dips below what you asked for.

!
Watch Out

Allowing a surge only works if the cluster has spare room for the extra Pods. If it does not, the update stalls while the extra Pods wait, unscheduled, for space that never appears.

7Internal Working: A Rollout Step by Step

Now let us follow one release from the moment you change the version to the moment the last old Pod disappears.

1

You change the Pod template

You submit a new image version, or another template change, to the API Server, which saves it as the desired state.

2

The controller notices and creates a new ReplicaSet

Because the template no longer matches the existing ReplicaSet, a new ReplicaSet is created for the new version, starting with zero Pods.

3

The new ReplicaSet grows within the surge limit

The controller asks for new Pods, up to the allowed extra number. The scheduler places them and the kubelets start their containers.

4

Readiness checks decide what counts

A new Pod counts as available only after its readiness check passes, and, if configured, after a minimum waiting time has also passed.

5

The old ReplicaSet shrinks within the unavailable limit

As new Pods become available, the controller removes old Pods, but never so many that fewer than the minimum allowed remain available.

6

The Service adjusts its targets

Newly ready Pods are added to the Service, and Pods being removed are taken off it, so users are always sent to healthy copies.

7

The steps repeat until the swap is complete

Grow, wait for readiness, shrink, repeat. When the new ReplicaSet has all the Pods and the old one has none, the rollout is complete.

8

The old ReplicaSet is kept, empty, for rollback

The old ReplicaSet stays in the cluster with zero Pods, as a saved record of the previous version. A limit on how many such records are kept applies, ten by default.

sequenceDiagram
  participant Op as Operator
  participant API as API Server
  participant DC as Deployment controller
  participant New as New ReplicaSet
  participant Old as Old ReplicaSet
  participant Svc as Service
  Op->>API: Change image version
  API->>DC: Template changed
  DC->>New: Create with zero Pods
  DC->>New: Scale up within surge limit
  New-->>Svc: New Pod becomes ready
  DC->>Old: Scale down within unavailable limit
  Old-->>Svc: Old Pod removed from targets
  DC->>New: Scale up again
  DC->>Old: Scale down again
  Note over New,Old: Repeat until the old version has no Pods
        
FIG 2 — The conversation between controller, ReplicaSets and Service during a rollout
i
Good to Know

The controller works in small, cautious steps and rechecks the situation each time. It never rushes ahead of readiness. That patience is exactly what makes the process safe, and also what makes a broken new version stall the rollout instead of spreading damage.

“A rolling update moves only as fast as the slowest ready check.”

8Readiness: The Guard at the Door

The most important ingredient of a safe update is a truthful readiness check.

What readiness means

A readiness check is a small test that Kubernetes runs against a container to ask, “are you ready to serve users right now?” The test may ask a program to answer a simple request, open a network connection or run a small command. Until it passes, the Pod receives no traffic, and, crucially for updates, the Pod does not count as available.

Simple Analogy

A new waiter should not be sent to a table until he has learned the menu. The head waiter quizzes him first, and only when he passes does he take orders. Readiness is that quiz, and the rolling update will not remove an experienced waiter until the newcomer has passed it.

What goes wrong without it

No readiness check at all

Kubernetes treats a Pod as ready as soon as its container starts. The rollout races ahead, removing old Pods while the new ones are still loading, and users see errors during the update.

A check that is too shallow

If the check only asks whether the process is running, it says yes even when the program cannot reach its database. Broken copies then join the service.

A check that is too strict

If it fails because of a temporary hiccup in a downstream service, healthy copies are pulled out unnecessarily and the rollout stalls.

A check that starts too early

A slow application fails its first few checks simply because it is still starting. Give it an initial delay or use a start-up check, so it is not judged before it has had time to wake up.

Minimum ready time

The Deployment also has a setting called the minimum ready time. It says how many seconds a new Pod must stay ready, without crashing, before it counts as available. The default is zero. A small value, such as ten to thirty seconds, catches copies that pass the first check but crash a moment later, before the rollout moves on and removes more old Pods.

CheckQuestion it answersEffect on a rolling update
Start-up checkHas the application finished starting?Protects slow starters from being judged too early
Readiness checkCan it serve users now?Decides whether the new Pod counts as available
Liveness checkIs it stuck and in need of a restart?Restarts frozen containers, indirectly affecting rollout speed
Minimum ready timeHas it stayed ready long enough to trust?Delays the next step until the new Pod has proved stable
!
Frequent Beginner Slip

Believing that a running container is a ready container. Running means only that the process started. Ready means it can actually do its job. The rolling update depends entirely on that distinction.

9Saying Goodbye Gracefully: Removing Old Pods

Starting new Pods is only half the story. Old Pods must leave without dropping the requests they are serving.

What happens to an old Pod

When the controller removes an old Pod, Kubernetes marks it as terminating and begins to take it out of the Service’s list of targets. In parallel, the kubelet on its machine runs any pre-stop step, then sends a polite stop signal to the program, and waits for a grace period, thirty seconds by default. If the program is still running after that time, it is stopped by force.

1

The Pod is marked terminating

It is no longer counted as a ready target for new requests.

2

The Service and network layers update

The news that the Pod is leaving spreads to the parts that route traffic. This takes a short but real amount of time.

3

An optional pre-stop step runs

Often a short pause, giving the network time to catch up before the program is told to stop.

4

The program receives the stop signal

A well-behaved program stops accepting new work, finishes current requests and exits.

5

After the grace period, a forced stop

Anything still running is ended, so long requests may be cut off if the grace period is too short.

The hidden race

Steps two and four happen at almost the same time. If the program stops instantly on receiving the signal, a few requests that were already on their way may still reach it and fail. This is a well-known cause of small bursts of errors during otherwise smooth updates. The cure is a short pause before shutdown, achieved with a pre-stop step or by having the program keep serving for a few seconds after the signal arrives.

Simple Analogy

A shop announces that it is closing, and puts up the sign. But customers already walking down the street have not seen it yet. A sensible shopkeeper keeps the door open for a few minutes, serves those who arrive, and only then locks up.

Setting 1

Grace period

How long the program has to finish. Match it to your longest normal request, with a margin.

Setting 2

Pre-stop pause

A short delay that lets traffic routing catch up before shutdown begins.

Behaviour 1

Handle the stop signal

The program should stop accepting new work, finish current requests and close connections cleanly.

Behaviour 2

Report not ready while draining

A good program starts failing its readiness check as soon as it begins shutting down, so no new work is sent its way.

i
Practical Tip

If you see a brief spike of errors at every release, suspect this shutdown race first. Adding a small pre-stop pause and making sure the program handles the stop signal cleanly often removes those spikes entirely.

10Watching and Controlling a Rollout

You are not a passenger. You can watch, pause, resume and reverse a rollout while it happens.

Action 1

Watch the status

A rollout status action follows the update live and reports how many copies are updated and available, ending with a success or failure message.

Action 2

View the history

A history action lists past versions of the Deployment, each with a revision number, so you know what you can go back to.

Action 3

Pause

Freezes the rollout at its current point. Useful for inspecting the new copies, or for making several template changes together without a rollout for each.

Action 4

Resume

Continues a paused rollout, applying all the changes made while it was paused as one combined update.

Action 5

Undo

Rolls back to the previous version, or to a chosen revision. The rollback itself is a rolling update in the other direction.

Action 6

Restart

Triggers a fresh rolling replacement of every Pod without changing the version, handy for picking up new settings.

Recording why a change happened

The history lists revisions, but not the reasons behind them. You can attach a short note, called a change cause, to each revision. It might say “upgrade to version three point two” or “fix login bug”. Six months later, when someone asks why the version changed, the note is worth its weight in gold.

Rollback is a rollout too

When you undo a release, Kubernetes does not rewind time. It simply makes the old version’s template the desired state again and performs another rolling update, growing the old ReplicaSet and shrinking the new one with the same careful rules. This is why keeping old ReplicaSets matters, and why deleting them by hand removes your ability to go back.

Simple Analogy

Rolling back is like a train reversing along the same track. It is not instant, since the carriages must move one by one, but it is orderly and safe, and every station along the way is already known.

!
Common Mistake

Assuming that a rollback also reverses changes to other objects, such as settings bundles or database structure. Undo restores only the Pod template of the Deployment. Anything else you changed must be reversed separately.

11When a Rollout Gets Stuck

A rollout that cannot make progress is not a disaster. It is the safety system doing its job.

What a stuck rollout looks like

If new Pods never become ready, the controller stops removing old ones. The result is a half-finished update: some copies at the old version, some at the new, and the rollout status waiting. Your users are still being served by the old copies, which is exactly the protection you wanted.

The progress deadline

The Deployment has a setting called the progress deadline, ten minutes by default. If no progress is made within that time, Kubernetes marks the Deployment as not progressing and records the reason. It is important to understand that Kubernetes does not undo the release on its own. It reports the situation, and leaves the decision to you or to your automation.

flowchart TD
  R["Rollout is not finishing"] --> Q{"New Pods created?"}
  Q -->|"No"| A1["Check quota and Deployment events"]
  Q -->|"Yes but Pending"| A2["Not enough room or unmet placement rules"]
  Q -->|"Yes but image error"| A3["Check image name, tag and credentials"]
  Q -->|"Yes but crashing"| A4["Check logs and last exit reason"]
  Q -->|"Yes but not ready"| A5["Check readiness check and dependencies"]
  A1 --> F["Fix the cause or undo the release"]
  A2 --> F
  A3 --> F
  A4 --> F
  A5 --> F
        
FIG 3 — A quick map for diagnosing a rollout that will not finish

New Pods stay Pending

There is no room for the extra surge Pods, a quota is reached, or placement rules cannot be satisfied. Free up room, add machines, or lower the surge.

ImagePullBackOff

The new image cannot be downloaded because the tag is wrong, does not exist, or credentials for a private registry are missing.

CrashLoopBackOff

The new version starts and crashes. Read the logs of the previous run and the container’s last exit reason. Common causes are a missing setting, a bad configuration value or an out-of-memory kill.

Running but never ready

The application starts but its readiness check fails, perhaps because it cannot reach a dependency or the check itself is misconfigured for the new version.

Rollout very slow rather than stuck

Pods are healthy but slow to start, images are large, or the minimum ready time and surge settings are conservative. Measure how long each step takes before tuning.

i
Good Habit

When a rollout stalls, describe the Deployment and its new Pods first. The events almost always name the reason, and this costs nothing. Only then decide whether to fix forward or to undo.

12Living with Two Versions at Once

The hardest part of rolling updates is not Kubernetes. It is your own application.

During a rolling update, the old and the new versions of your application serve users at the same time, sometimes for minutes. They read and write the same database, call the same services and may handle successive requests from the same user. If the two versions cannot coexist, users will see errors even though Kubernetes did everything right.

Where clashes appear

Clash 1

Database structure

The new version expects a new column, but the old version, still running, knows nothing about it, or the other way round.

Clash 2

Message formats

The new version sends messages that the old version cannot read, or reads only a newer format.

Clash 3

Interface changes

A front-end talks to a back-end whose interface changed, so a user might hit the new front-end and the old back-end.

Clash 4

Cached data and sessions

Data saved by one version is misread by the other, logging users out or corrupting cached items.

The safe habit: change in two steps

1

Expand first

Release a version that can work with both the old and the new data shape, adding, for example, an optional new column that nothing depends on yet.

2

Switch usage

Release the version that actually uses the new shape, once every running copy understands it.

3

Contract last

Only after the switch is complete and stable, remove the old column or the old format in a later release.

Simple Analogy

Imagine a country switching from driving on the left to the right. It would not change overnight for every car at once. Careful planning would ensure that during the transition, signs, junctions and cars can cope with both. Rolling updates ask the same of your software: be polite to your neighbour, the other version.

!
Common Mistake

Combining a breaking database change and a new application version in a single release, then blaming the rolling update for errors. If two versions cannot coexist, use the Recreate strategy or a blue-and-green approach, and accept the trade-off.

13Rolling Updates for StatefulSets and DaemonSets

Other kinds of workloads update gradually too, but with rules that fit their nature.

StatefulSets: one at a time, in reverse order

A StatefulSet runs programs that remember things, such as databases, and gives each Pod a fixed number and its own storage. Its rolling update replaces one Pod at a time, starting from the highest number and working down. It waits for each new Pod to be running and ready before touching the next. This careful order protects clustered programs and their data.

A StatefulSet also has a partition setting. It tells the update to change only the Pods whose numbers are at or above a chosen value, leaving the lower ones alone. This makes it easy to try a new version on a few Pods first, in the style of a canary, before finishing the rest.

DaemonSets: one Pod per machine

A DaemonSet runs one Pod on each machine, for example a log collector. Its rolling update replaces Pods machine by machine, by default one machine at a time. A surge option, in newer versions, lets a new Pod start before the old one on the same machine stops, reducing gaps for services such as log collection or networking.

The manual alternative

Both kinds also offer an option where Kubernetes does not replace Pods on its own. Instead, a new version is applied to a Pod only when someone deletes that Pod by hand. This gives complete control for delicate systems, at the cost of doing the work manually.

WorkloadDefault update behaviourSpecial controlsTypical care needed
DeploymentRolling update with surge and unavailable limitsPause, resume, history, undoCompatible versions and readiness checks
StatefulSetOne Pod at a time, highest number firstPartition to update only some PodsData safety and application-level rebalancing
DaemonSetMachine by machine, usually one at a timeUnavailable and surge limitsGaps in machine-level services
Simple Analogy

A Deployment is like repainting identical buses. A StatefulSet is like renovating the numbered rooms of a hotel, one at a time from the top floor, checking that each room is habitable before moving on. A DaemonSet is like servicing the fire extinguisher on every floor, one floor after another.

14Designing for Zero Downtime

Zero downtime is not a switch. It is the result of several small decisions working together.

1

Run at least two, preferably three, copies

A single copy cannot be replaced without a gap. With several, the others keep serving.

2

Set maximum unavailable to zero

Keep a small surge so a new copy is always ready before any old one is removed.

3

Write honest readiness checks

Make them reflect real ability to serve, including reaching essential dependencies.

4

Add a minimum ready time

Let each new copy prove itself for a short while before the rollout continues.

5

Shut down gracefully

Handle the stop signal, add a short pre-stop pause and set the grace period to suit your longest request.

6

Spread copies across machines and zones

Placement rules ensure that the loss of one machine, during or outside an update, does not remove too many copies at once.

7

Keep versions compatible

Use the expand, switch and contract habit for data and interface changes.

8

Reserve spare capacity

Make sure the cluster can hold the extra surge Pods without waiting for new machines.

i
Disruption Budgets

A Pod Disruption Budget protects your minimum number of copies during voluntary disruptions, such as draining a machine for maintenance. It does not control the Deployment’s own rolling update, which follows the surge and unavailable settings instead. Use both: the settings for releases, and the budget for machine maintenance.

!
Long-lived Connections

Connections that stay open for a long time, such as streaming connections, stay attached to whichever copy they first reached. After an update, some users may remain on old copies until their connection ends, and new copies may receive fewer connections than expected. Plan how clients reconnect.

15Security Considerations

A release is the moment when new code enters your system. It deserves careful protection.

Who may release

Changing a Deployment’s Pod template is a powerful act: it decides which code runs in production. Kubernetes access control lets you decide who may update Deployments, and in which namespaces. Give release rights only to trusted people and automation, and prefer a reviewed pipeline over hand-typed commands.

What enters the cluster

Risk 1

Untrusted images

An image from an unknown source may contain harmful code. A rolling update will faithfully deploy it everywhere.

Risk 2

Moving tags

A tag that can be overwritten lets someone change what runs without changing the Deployment. Fixed digests remove this risk.

Risk 3

Vulnerable versions

A release may reintroduce a known security flaw. Scanning before release catches many of these.

Risk 4

Untraceable changes

Without records, nobody knows who released what and when, which slows down investigation.

Safeguard 1

Scan and sign images

Scan images for known flaws and verify signatures before they may run in the cluster.

Safeguard 2

Allow only trusted registries

Use admission policies that reject images from unapproved sources.

Safeguard 3

Pin by digest

Refer to images by their content fingerprint so that what runs is exactly what was tested.

Safeguard 4

Audit every release

Turn on audit logs and record change causes, so every release can be traced to a person and a reason.

i
Good Habit

Let a pipeline perform releases, with human approval for production. It leaves a trail, applies the same steps every time and removes the temptation of quick manual fixes.

16Monitoring a Rollout

A rollout is not finished when the last Pod starts. It is finished when you know the new version is healthy.

The counts a Deployment reports

CountMeaningWhat it tells you during a rollout
Desired replicasThe number you asked forYour target
Updated replicasPods running the new templateHow far the release has progressed
Ready replicasPods that passed readinessHow many can serve users
Available replicasReady for at least the minimum timeThe number the controller trusts when removing old Pods
Unavailable replicasWanted but not yet availableShould shrink to zero as the rollout completes

Signals of user experience

The counts tell you about Pods, not about people. Alongside them, watch what users feel: error rates, response times, the number of restarts, and any business signals such as completed orders. Compare the numbers before, during and after the release. A rollout that completes cleanly but doubles the error rate is a failed release, and the counts alone would never tell you.

Errors
should not rise during the release
Latency
should stay close to the old version
Restarts
new Pods should not keep restarting
i
Practical Tip

Label the new Pods with their version, so that dashboards can compare old and new copies side by side while both are running. If the new copies look worse, you will see it within minutes, while most users are still on the old version.

!
Common Mistake

Declaring victory the moment the rollout status says complete. Some problems, such as memory leaks and slow queries, appear only after the new version has been running for a while. Keep watching for a defined period after every release.

17Anti-patterns to Avoid

These mistakes appear again and again in real teams. Learn to recognise them early.

ANTI-PATTERN-01 Avoid
Problem

The Deployment has no readiness check, so every new Pod is considered ready the moment its container starts.

Why It’s Harmful

The rollout races ahead and removes old Pods while new ones are still loading. Users see errors during every release.

Correct Approach

Add a truthful readiness check, and a start-up check for slow applications, before relying on rolling updates.

ANTI-PATTERN-02 Avoid
Problem

Production runs the image tag latest, or any tag that gets overwritten.

Why It’s Harmful

Nobody can say which code is running, rollbacks do not restore what you think, and different Pods may run different code.

Correct Approach

Use unique, immutable version tags, or better, pin images by digest.

ANTI-PATTERN-03 Avoid
Problem

A single copy of an important service is updated with a rolling update.

Why It’s Harmful

With one copy, there is nothing left to serve while it is replaced, so there is a gap despite the gentle strategy.

Correct Approach

Run at least two copies of anything that matters, and set the maximum unavailable to zero.

ANTI-PATTERN-04 Avoid
Problem

A breaking database change and a new application version are released together, relying on the rolling update to sort it out.

Why It’s Harmful

For minutes, old and new versions disagree about the data, causing errors and possibly corrupted records.

Correct Approach

Change data in expand, switch and contract steps, or use a strategy that never runs two versions together.

ANTI-PATTERN-05 Avoid
Problem

Old ReplicaSets are deleted by hand to “tidy up”, or the history limit is set to zero.

Why It’s Harmful

Rollback needs those records. Removing them turns a quick undo into a slow, risky rebuild under pressure.

Correct Approach

Keep a sensible number of revisions, and let the system remove old ones automatically according to the limit.

ANTI-PATTERN-06 Avoid
Problem

The team ignores stalled rollouts, assuming that Kubernetes will fix or reverse them automatically.

Why It’s Harmful

Kubernetes only reports a stalled rollout. It does not undo it. The application may run half old and half new for days, with confusing behaviour.

Correct Approach

Alert on failed rollouts, decide quickly whether to fix forward or undo, and automate the check in your pipeline.

ANTI-PATTERN-07 Avoid
Problem

Large unavailable settings are used in production to make releases faster.

Why It’s Harmful

Capacity dips during each release, and a busy period combined with a release can overload the remaining copies.

Correct Approach

Keep the unavailable count at zero for important services, and gain speed through a larger surge and faster start-up instead.

18Best Practices and Common Mistakes

A short checklist of good habits, in the order you are likely to need them.

1

Test before the release, not during it

Use testing environments and automated checks so that obvious failures never reach production.

2

Use immutable, unique image versions

Every release should be traceable to one exact image, and one exact commit of your code.

3

Tune the two dials deliberately

Pick the surge and unavailable values for each service, according to its importance and the room you have.

4

Invest in health checks

Truthful start-up, readiness and liveness checks are the foundation of safe rollouts.

5

Set a progress deadline that fits your application

Make it longer than your slowest normal rollout, and short enough to notice real trouble.

6

Automate the verdict

Let your pipeline wait for the rollout, check user-facing signals and undo automatically on failure.

7

Record the reason for every change

Add a change cause, and keep release notes, so history is understandable months later.

8

Practise rollbacks

Undo a release in a testing environment from time to time, so the first real rollback is not also the first rehearsal.

!
Frequent Beginner Slip

Believing that a rolling update makes any release safe. It limits how much damage a bad release can do before you notice, but it cannot fix a bad release, an incompatible data change or a missing health check.

19Real-World and Industry Examples

See how ordinary teams use rolling updates every day.

Daily releases at an online retailer

A shopping site releases many times a day. Each release uses a rolling update with zero unavailable Pods, so customers browsing at midday never notice. A bad build stalls in the first few copies and is reversed within minutes.

A bank patching a security flaw

When a serious library flaw is announced, the bank rebuilds its services with the fix and rolls them out in stages, first to a testing cluster and then to production, keeping everything available while thousands of Pods are replaced.

A streaming service and long connections

Viewers hold long connections. The team gives Pods a generous grace period and teaches clients to reconnect smoothly, so that the release of a new version simply moves viewers to new copies over time.

A database-backed service with careful migration

A company changing a table structure ships three releases over a week: first one that understands both old and new columns, then one that uses the new column, and finally one that removes the old. Every step is a plain rolling update.

A stalled rollout saved by readiness

A new version cannot reach its database because of a wrongly typed setting. Its readiness check fails, so the controller never removes the old copies. Users notice nothing, and the engineer fixes the setting and continues.

A log collector updated machine by machine

A platform team updates the log collection agent, a DaemonSet, one machine at a time, with a surge so that each machine has no gap in log collection during the swap.

A quick restart to pick up new settings

After editing a settings bundle, an operator triggers a rolling restart. The Pods restart gradually with the new settings, with no downtime, and the change is complete within minutes.

20Advantages and Trade-offs

Every strategy has strengths and limits. Knowing both keeps your expectations realistic.

Advantages

  • Keeps the application available throughout the release
  • Limits the damage of a bad release, because it spreads slowly
  • Built in and used by default, with no extra tools
  • Controllable through simple surge and unavailable settings
  • Easy to pause, resume and reverse
  • Needs only a little spare capacity

Disadvantages / Trade-offs

  • Old and new versions run together, demanding compatibility
  • Rollbacks are gradual rather than instant
  • Depends completely on the quality of health checks
  • Kubernetes reports stalled rollouts but does not undo them itself
  • Long connections and shutdown races can cause small bursts of errors
  • Gives no fine control over which users see the new version
Simple Analogy

A rolling update is like swapping the crew of a moving train, carriage by carriage. It keeps passengers travelling and limits any mistake to one carriage at a time, but the crews must be able to work together, and if you want only a chosen group of passengers to try the new crew first, you need a different arrangement.

21Frequently Asked Questions

Quick answers to the questions beginners ask most often.

Q1What is a rolling update in Kubernetes?

It is the default way a Deployment replaces old Pods with new ones gradually, keeping enough healthy Pods in service so that users are still served during the release.

Q2What starts a rolling update?

A change to the Pod template, such as a new image version, new environment settings, or a restart request. Changing only the replica count does not start one.

Q3What do max surge and max unavailable mean?

Max surge is how many extra Pods may exist during the update. Max unavailable is how many Pods may be missing. Together they set the pace and the safety margin.

Q4Why did editing my settings bundle not update my application?

The Pod template did not change, so no rollout began. Restart the Deployment, or give the bundle a new name or content fingerprint so that the template changes.

Q5How do I get zero downtime during updates?

Run several copies, set max unavailable to zero with a small surge, use truthful readiness checks, shut down gracefully and keep old and new versions compatible.

Q6Does Kubernetes roll back a failed update automatically?

No. It stops making progress and reports that the Deployment is not progressing after the progress deadline. You, or your pipeline, must decide to fix or undo.

Q7How do I undo a bad release?

Use the rollout undo action, optionally naming a revision. It performs another rolling update back to the earlier Pod template.

Q8Why is my rollout stuck?

New Pods are probably Pending, failing to pull their image, crashing or not becoming ready. Describe the Deployment and new Pods and read the events to find the cause.

Q9Do Pod Disruption Budgets control rolling updates?

No. They protect against voluntary disruptions such as draining machines. A Deployment’s rolling update follows its own surge and unavailable settings.

Q10Can I pause an update to inspect the new version?

Yes. Pausing freezes the rollout partway, letting you inspect the new copies. Resuming continues it. It also lets you batch several changes into one rollout.

Q11Is the tag latest safe to use?

Not for production. It hides which version is running, can differ between machines, and makes rollbacks unreliable. Use unique, immutable tags or digests.

Q12How do StatefulSets update?

One Pod at a time, from the highest number down, waiting for each to be ready. A partition setting lets you update only some Pods first.

22Summary and Key Takeaways

You began this guide in a restaurant, where a wise manager retrains her waiters one at a time so the doors never close. A rolling update does the same for your application. Kubernetes creates a new ReplicaSet for the new version and gradually shifts Pods from the old one to the new, guided by two dials, max surge and max unavailable, and by the readiness checks that decide when a new copy truly counts. You learned what triggers a rollout, how old Pods leave gracefully, how to watch, pause and undo a release, how to diagnose a stalled rollout, and how to design your application and your settings for zero downtime. Above all, you learned that the strategy protects you only as far as your health checks, your compatible versions and your habits allow. Get those right, and releases become gloriously boring.

Key Takeaways

  • Gradual replacement keeps you available — a rolling update swaps old Pods for new ones a few at a time, so enough healthy copies always serve users.
  • The Pod template is the trigger — only changes to the template start a rollout, so unchanged settings bundles or reused image tags will not update your application.
  • Two dials set the pace — max surge allows extra Pods and max unavailable allows missing ones; zero unavailable with a small surge is the safest choice for important services.
  • Readiness is the guard — truthful readiness checks decide when a new Pod counts, and without them the rollout races ahead and users see errors.
  • Leave gracefully — handle the stop signal, add a short pre-stop pause and set a sensible grace period to avoid bursts of errors when old Pods depart.
  • Kubernetes reports but does not roll back — a stalled rollout is flagged after the progress deadline, and you or your pipeline must fix it or undo it.
  • Two versions must coexist — use expand, switch and contract steps for data and interface changes, and pick a different strategy when versions cannot run together.