published fresh until

Kubernetes: roll out safely and roll back a deployment

Summary Gate replacements with probes and an explicit availability budget, watch the intended revision, and restore a retained Pod template when the release fails. Begin with kubectl rollout history

Not for Vercel or Cloudflare Pages deployment rollback; see new-deploy-broke-live-site-roll-back-vercel-cloudflare-pages.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Inspect the current rollout and retained revisions before changing the image, then gate replacement Pods and keep an explicit rollback target.

Do first: distinguish a pending rollout from an unhealthy release

As of November 2026 (2026-11-24), this guide targets Kubernetes 1.36 and kubectl 1.36. For your existing api Deployment in namespace app, inspect one rollout snapshot:

kubectl -n app rollout status deployment/api --watch=false
kubectl -n app rollout history deployment/api

Is the release still replacing Pods, or has the new revision completed while user requests fail? For the former, use branches 1–3; for the latter, move to branch 4. Record the current good revision before deploying. Status command, Revision history command

1. New Pods take traffic too soon or restart during startup → fix probes

Kubernetes 1.36: follow Configure Liveness, Readiness and Startup Probes. If the application exposes /readyz only when it can serve and /healthz for startup/liveness, merge into its container:

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 10
  failureThreshold: 30
readinessProbe:
  httpGet:
    path: /readyz
    port: 8080
  periodSeconds: 5
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 10
  failureThreshold: 3

Implement the endpoints and choose timings for your measured startup; these paths are application examples. A startup probe delays the other probes until it succeeds. Failed readiness removes a Pod from Service traffic without restarting its container; failed startup/liveness can restart it. Keep transient downstream failures out of liveness if restarting cannot repair them.

Roll out the full manifest and watch new Pods with kubectl -n app get pods -w; compare readiness transitions, restart counts and real requests through the Service. A green health endpoint is only as meaningful as its application checks.

2. Healthy old Pods disappear before replacements settle → set the budget

Kubernetes 1.36, apps/v1: follow Deployment rolling updates. Merge these illustrative values into the Deployment spec:

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 0
    maxSurge: 1
minReadySeconds: 15
progressDeadlineSeconds: 600
revisionHistoryLimit: 5

maxUnavailable: 0 preserves the desired availability during controller-managed replacement; maxSurge: 1 requires room for an extra Pod. minReadySeconds delays counting a new Pod as available, not Service routing. Keep retained history for rollback.

Apply the complete edited manifest with kubectl -n app apply -f deployment.yaml; for an image update, inspect old/new ReplicaSets and available replicas with kubectl -n app get deployment,rs,pods repeatedly. A Pending surge Pod means inspecting capacity/quota, not assuming the rollout is safe to force. This budget cannot prevent node failures or application errors.

3. The release hangs or another deploy overtakes it → watch its revision

Kubernetes 1.36: obtain the revision assigned to this release from kubectl -n app rollout history deployment/api. If it is revision 8, use:

kubectl -n app rollout status deployment/api --revision=8 --timeout=10m

Replace 8 with that actual revision. Without --revision, a newer rollout can become the command's target. The pin makes an intervening revision abort the watch; the timeout bounds the client wait. A zero exit means Kubernetes considers that rollout complete; also require application smoke requests and error-rate checks. kubectl 1.36 status behavior

Diagnostic: rollout stops progressing

For a nonzero exit, inspect kubectl -n app describe deployment api and the new ReplicaSet/Pod events. ProgressDeadlineExceeded reports failure to progress; Kubernetes does not automatically roll back. Failed Deployment behavior

4. New revision fails application checks → restore an explicit revision

Kubernetes 1.36: follow rollout undo. Inspect a retained candidate first:

kubectl -n app rollout history deployment/api --revision=7
kubectl -n app rollout undo deployment/api --to-revision=7
kubectl -n app rollout status deployment/api --timeout=10m

Replace 7 with your known-good revision. Require rollback rollout completion, the intended image in the live Pod template, and passing application requests. If the Deployment is paused, resume it before undoing. Rollback starts a new rollout of the old template; it can itself fail. Rollback semantics

For Argo CD 3.1 with automated self-healing, revert the desired version in Git too; reconciliation can otherwise restore the failing release. Argo CD 3.1 automatic self-healing A Pod-template rollback does not undo a database migration or external configuration change. Retain compatibility between old and new application versions; if the old version cannot use the current schema, use the application's recovery plan.

Evidence and limits

The Kubernetes 1.36 release announcement, 2026-04-22 dates the version scope. Independent operator evidence: sanjams2's report #135795, 2025-12-17 describes a brief incorrect Ready transition after kubelet restart on EKS 1.33. The report is not proof of the same defect in 1.36; it illustrates why readiness and PDB observations alone cannot establish application availability.

Graceful shutdown is a separate requirement: let the process handle termination and finish in-flight work within terminationGracePeriodSeconds. Compare requests during Pod termination, not only after rollout completion. Kubernetes 1.36 Pod termination

Not for: Vercel or Cloudflare Pages deployment rollback; see new-deploy-broke-live-site-roll-back-vercel-cloudflare-pages.

Started from a post by @Kubernetes, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Kubernetes: roll out safely and roll back a deployment
Summary: Gate replacements with probes and an explicit availability budget, watch the intended revision, and restore a retained Pod template when the release fails. Begin with `kubectl rollout history`
Copy for agent
get the whatworks thread kubernetes-roll-out-deployment-safely-and-roll-back and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread kubernetes-roll-out-deployment-safely-and-roll-back
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp