Core Kubernetes · 09

Rollouts and Probes

1.What starts a rollout ?

A rollout swaps Pods from an old ReplicaSet to a new one. Pods are never edited in place.

  • Trigger : any change under .spec.template (image, env, labels...). Each one makes a new ReplicaSet, a new revision.
  • Changing replicas is scaling, not a rollout.
  • .spec.strategy.type : RollingUpdate (default) or Recreate.
  • Recreate : all old Pods gone first, then the new ones. Downtime by design.

ReplicaSets and scaling : Deployments and Scaling.

New template image, env, labels triggers Deployment controller moves one step at a time up, total 5 at most down, keep 3 or more available New ReplicaSet rev N+1, scales up Old ReplicaSet rev N, scales down creates a Pod New Pod is Ready readinessProbe passes Available after minReadySeconds next step replicas: 4 maxSurge 25% = 1 maxUnavailable 25% = 1 so 3 to 5 Pods during the update

2.Step size

  • maxSurgePods allowed above replicas. 25%, rounds up.
  • maxUnavailablePods allowed to be unavailable. 25%, rounds down.
  • both 0Rejected : the rollout could never move.

A number or a percent. It is not one Pod at a time : 10 replicas start 3 extra Pods and drop 2 at once.

Terminating Pods do not count as available, so the real count can briefly pass max Pods until their grace period ends.

replicassurgeunavailablemin availablemax Pods
11012
31034
41135
1032813
Not a strategy typeBlue/green flips one Service selector from the old Deployment to the new one. Canary runs both behind one shared label, or splits traffic by weight (Gateway API, Knative, Flagger from the Flux project).

3.Readiness sets the pace

A new Pod is available once it is Ready and stays Ready for minReadySeconds (default 0). Beyond maxUnavailable, old Pods only go as new ones become available.

  • No readinessProbe ? Ready the moment it starts, so traffic and the rollout run ahead of the app.
  • A new Pod that never gets Ready stalls the rollout. Old Pods keep serving.
  • Capacity can dip by default. maxUnavailable: 0 keeps full capacity.
Progressingreasonrollout status
TrueNewReplicaSetAvailableexits 0
TrueReplicaSetUpdatedkeeps waiting
FalseProgressDeadlineExceededexits 1
Stalled is only a statusNo progress for progressDeadlineSeconds (default 600, must be greater than minReadySeconds) gives the False row. The controller keeps retrying and never rolls back. That is your job.

4.Revisions and rollback

  • Each ReplicaSet is a revision. revisionHistoryLimit (default 10) is how many old ones stay. 0 means no undo.
  • rollout undo reverts the Pod template only.
  • The reused ReplicaSet gets a new number : rev 2 comes back as rev 4.
  • Resume a paused Deployment before you undo.
rev 1 nginx:1.14.2 rev 2 nginx:1.16.1 rev 3 nginx:1.161 (typo) each set image = a new ReplicaSet ImagePullBackOff, stalls, you act rollout undo --to-revision=2 rev 4 rev 2's ReplicaSet reused undo patches the template, rev 3 scales to 0 Pods.
In short : A template change makes a new ReplicaSet, maxSurge and maxUnavailable size each step, readiness sets the pace, and a stalled rollout waits for you to undo it.

1.Three probes, three jobs

The kubelet runs the probes. Liveness and readiness run side by side and never wait for each other.

Container starts initialDelaySeconds startupProbe if set, runs first Kill container then restartPolicy backoff up to 300s fails restart first success livenessProbe every periodSeconds fails readinessProbe whole life fails passes Ready = False no new Service traffic keeps running Ready = True gets Service traffic counts for rollouts
ProbeOn failureUse it for
startupKill, restartPolicySlow starters. The others wait.
livenessRestart, same Pod, same nodeHangs. Never a dependency check.
readinessNo Service traffic, no restartWarm-up, overload, deps down

One check per probe. No probe counts as Success.

  • execthe command exits 0
  • httpGetstatus 200 to 399
  • tcpSocketthe port accepts a connection
  • grpchealth check says SERVING (GA v1.27)

2.Probes in a Pod template

containers:
- name: nginx
  image: nginx:1.16.1
  ports: [{name: http, containerPort: 80}]
  startupProbe:
    httpGet: {path: /, port: http}
    periodSeconds: 5
    failureThreshold: 12  # up to 60s to start
  readinessProbe:
    httpGet: {path: /, port: http}
    periodSeconds: 5
  livenessProbe:
    tcpSocket: {port: http}

3.Timing

FieldDefaultNote
initialDelaySeconds0From container start. Liveness and readiness also wait for startupProbe
periodSeconds10How often
timeoutSeconds1One try fails after this
successThreshold1Only 1 for liveness, startup
failureThreshold3Fails in a row = failed
Startup budgetfailureThreshold x periodSeconds. Here 12 x 5 = 60s. The docs example uses 30 x 10 = 300s.

4.Readiness gates

  • spec.readinessGates[].conditionType adds a Pod condition that an outside controller sets.
  • Ready = containers ready and every gate True. Missing counts as False.
PodDisruptionBudgetpolicy/v1. Limits voluntary evictions (Eviction API, kubectl drain). Deleting Pods and rolling updates skip it, since maxUnavailable is the rollout's own budget. Healthy = Ready, and maxUnavailable: 0 means drain never ends.

5.Commands

CommandWhat it does
kubectl set image deployment/web nginx=nginx:1.16.1Changes the template image, so a rollout starts
kubectl rollout status deployment/web --timeout=5mWaits. Exit 0 when done, 1 once past the deadline
kubectl annotate deployment/web kubernetes.io/change-cause="to 1.16.1"Fills CHANGE-CAUSE in history (replaces --record)
kubectl rollout history deployment/web --revision=2Lists revisions, or one revision's template
kubectl rollout undo deployment/web --to-revision=2Back one revision, or to N. --dry-run=server previews
kubectl rollout pause / resume deployment/webBatches edits into one revision (Deployments only)
kubectl rollout restart deployment/webNew Pods for all, through a normal rolling update
kubectl describe pod <pod>Probe failures show as Warning Unhealthy events
kubectl create pdb web-pdb --selector=app=web --min-available=50%A budget (or --max-unavailable, never both)
In short : Startup holds the other probes off, liveness restarts a stuck container, readiness pulls a Pod out of traffic, and that same Ready flag paces rollouts and PDBs.