Skip to lesson
supraj.dev THE ENGINEERING HANDBOOKS
LEARN / BUILD / VERIFY2026 edition · checked 06 Oct

CHAPTER 06 / 30 · Understand the cluster

Deployments, ReplicaSets and rolling changes

Trace a template change through rollout while separating availability from application correctness.

4 min read + practiceWorked exerciseInterview practice

The mechanism

A Deployment manages ReplicaSets, which manage Pods. Changing the Pod template creates a new rollout revision rather than editing running containers in place. The rollout strategy controls how old and new replicas overlap.

A rolling update trades temporary capacity against availability. maxSurge permits extra replicas; maxUnavailable permits some desired capacity to be unavailable during the transition. These settings interact with readiness, scheduling capacity and application compatibility.

ParcelOps should tolerate old and new versions running together during a rollout. Database schema changes, queue message formats and external API assumptions need their own compatibility plan. Kubernetes cannot infer whether two application versions can safely share state.

Deployment template
New ReplicaSet
Ready new Pods
Old replicas reduced

Worked example

This offline manifest fragment shows rollout intent. The image is an intentionally non-runnable placeholder; replace it with a reviewed artifact only in an approved environment. It is not a complete hardened production manifest.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: parcelops
  namespace: handbook-lab
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels: {app: parcelops}
  template:
    metadata:
      labels: {app: parcelops}
    spec:
      containers:
        - name: api
          image: registry.example/parcelops/api:reviewed-version

Practice: predict, inspect, explain

Offline exercise. With two desired replicas, calculate the maximum temporary Pod count under this strategy. Then assume the new version never becomes ready. Explain why the rollout can stall while old replicas keep serving, and why insufficient capacity for the surge Pod can also block progress.

Expected observation: the intended maximum is three Pods during the rolling transition, subject to lifecycle details and actual observed state. Record readiness and rollout conditions rather than declaring success immediately after the manifest is accepted.

Troubleshooting and trade-offs

If a rollout stalls, inspect new-Pod events, readiness and resource constraints. If rollback restores the image but the application still fails, investigate external data or schema changes. A Deployment rollback does not reverse every downstream effect. Avoid treating a successful rollout condition as proof that business transactions remain correct.

Interview practice

What triggers a new Deployment rollout?

A change to the Pod template triggers a new rollout. Scaling replica count alone is different from changing the template.

Why can zero unavailable replicas still stall?

The new Pod may never become ready or may not fit on available nodes. The strategy preserves availability intent but cannot create missing capacity or fix application health.

Completion check

Calculate the overlap budget and explain the stalled-readiness and insufficient-capacity cases.

Sources and version notes

Baseline checked 6 October 2026: the official release page lists Kubernetes 1.37.1. Verify your cluster and distribution prerequisites. All manifests are offline teaching examples; no cluster mutations or cloud resources are executed by this handbook.

YOUR NEXT STEP

Make the understanding yours.

Use the completion check above. Mark this chapter when you can explain the mechanism and its limits.

Self-assessed reading progress. This does not certify that a lab ran or a system is secure.