# Rolling update

## What it is

A rolling update replaces running instances of an application in steps. Some instances remain available while the system brings up replacements and removes the older version. During the transition, an old and a new version can serve requests at the same time. The updating controller follows a desired state and a set of limits that govern how quickly it changes the live population.

Kubernetes Deployments implement this through ReplicaSets. For a Deployment using the RollingUpdate strategy, maximum surge limits how many additional replicas the controller can create during the rollout. Maximum unavailable limits how many replicas may be unavailable relative to the desired count. An available replica has to meet the Deployment's readiness conditions long enough where a minimum ready time is configured. Capacity and readiness influence what the controller can safely do next.

A rolling update describes the replacement process. A sound release also defines the artifact, the changes made to shared dependencies and the conditions under which an operator can stop or roll back. For a stateful service, volume ownership and ordered replacement may call for a different controller or a more specific plan. Identify what remains shared while versions overlap, because compatibility across that period is part of the design.

## Why it matters

Replacing every instance at once can produce a noticeable outage even if the new image is healthy. Startup, connection establishment and cache warming take time. Maintaining a working population during replacement gives clients somewhere to go while the new instances start. It can also give operators time to notice an unexpected decrease in request success while some old capacity is still available.

The trade-off is that both versions may receive requests during the rollout. A client can call one version for a read and another for a write. Instances can use the same database, cache or job queue. A change that removes a field the old code still needs can fail even if the new code works by itself. Create a compatibility period for shared formats, then remove old support after the affected instances and clients have moved.

Capacity must be planned along with compatibility. An additional replica needs resources where it lands, and existing connections can continue briefly as an old instance terminates. If replacement Pods wait for space, a rollout can stay pending while the original application still serves traffic. Test the effect of limited resources and identify which observation signals that the release is making progress. Readiness, request success and available capacity tell different parts of that story.

## What it looks like in practice

Consider a service with three desired replicas. Use an illustrative rollout policy that permits one extra replica and requires all three to remain available. The controller can start a fourth instance while the old three are eligible for traffic. Once the replacement becomes available, it can remove one old instance and continue. In a live cluster, a terminating Pod can still occupy capacity while it shuts down. Include that overlap when estimating the resources the rollout needs.

An application release can add a database column in a backwards-compatible step and deploy code that handles both relevant row shapes. Test an old instance receiving a request after the schema change. Then test the new instance reaching the expected ready condition before directing requests to it. Keep a separate later transition for dropping obsolete data or tightening requirements once the compatibility period is over.

Engineer's GIS SaaS delivery case study describes making test, build and deployment repeatable with GitHub Actions and consistent configuration. A repeatable pipeline gives a rolling deployment the same kind of foundation. The automation can identify the precise image, wait for readiness and collect service observations before it reports release success. The example here makes those checks explicit for a Kubernetes workload.

## Where it goes wrong

A rollout can appear complete from the number of running processes while the service's response has changed for users. A Pod might respond to a simple endpoint and still fail on an important application request. Observe a real read path, the expected response code and any important dependency calls before accepting the new version. Record the revision serving each test so results from the old instances are easy to identify.

Keep the build identity visible to operators and to checks that can reach individual instances. During overlap, total error rates can hide a fault concentrated in the single new replica. Group the results by release for the duration of the rollout and compare the experienced request rate as well as the number of active Pods. Watch the same measures during the final replacement, when the new version begins receiving the full share of normal traffic.

A stop or rollback also needs a plan. New releases sometimes write data in a format the old version cannot read. A rollback to that version can then leave requests failing even after the earlier image starts. Rehearse recovery while both versions have access to representative data. Give operators a condition that distinguishes a deployment that is merely slow from one with no usable replacements. A rollout's progress deadline helps report stalled progress, and the response still needs an explicit decision.

Finally, consider draining and queued work. A replacement system can stop new traffic to an old instance while clients and workers still hold existing connections. Keep request handling bounded, and test what happens to active users when the old process is removed. A reliable rolling update leaves enough evidence to explain which instance served an operation, how data remained compatible, and what the system does when the release stops progressing.

## Further reading
* Kubernetes Deployments. Describes rolling update settings, availability and rollout status.
* Kubernetes rolling-update tutorial. Shows how traffic stays available during incremental replacement.
* kubectl rollout reference. Documents rollout observation and supported control commands.

=> /portfolio/automated-gis-saas-deployment-with-github-actions/ GIS SaaS delivery case study
=> https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ Kubernetes Deployments
=> https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/ Kubernetes rolling-update tutorial
=> https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/ kubectl rollout reference

=> https://engineer.company/glossary/rolling-update/ This page on the web
