Rollouts and debugging

Update a Deployment without downtime, undo it in one command, and work through a broken pod methodically.

Rollouts

Updating a Deployment's pod template starts a rolling update. Kubernetes brings new pods up and old ones down according to maxSurge and maxUnavailable, keeping the desired number of replicas serving throughout.

kubectl set image deployment/web web=nginx:1.28-alpine
kubectl rollout status deployment/web        # blocks until finished
kubectl rollout history deployment/web
kubectl rollout undo deployment/web          # back to the previous revision
kubectl rollout undo deployment/web --to-revision=3
kubectl rollout restart deployment/web       # restart pods without changing the spec
SettingEffect
maxUnavailable: 0No capacity dip, but the update then needs room for a surge pod
maxSurge: 1One extra pod at a time, the usual safe default
minReadySecondsRequire a pod to stay ready before it counts as available
progressDeadlineSecondsHow long a stalled rollout may sit before it is reported as failed
revisionHistoryLimitHow many old ReplicaSets are kept for undo

Debugging a failing pod

kubectl get pods -w
kubectl describe pod web-7d9c8b6f4-abcde     # events are at the bottom
kubectl logs web-7d9c8b6f4-abcde
kubectl logs web-7d9c8b6f4-abcde --previous  # the container that crashed
kubectl exec -it web-7d9c8b6f4-abcde -- sh
kubectl get events --sort-by=.lastTimestamp
  1. Read the status first. Pending, ImagePullBackOff, CrashLoopBackOff and Running each point at a different layer of the problem.
  2. Read the Events section of describe. It names the failing probe, the missing secret or the reason the pod is unschedulable.
  3. Get logs from the crashed container with --previous, because a restart wipes the current log.
  4. Diff a broken pod against a working one (kubectl get deploy web -o yaml). Labels, environment and image tags are the usual culprits.

A field guide to common failures

SymptomUsual cause
PendingNo node has the requested CPU or memory, or a taint has no toleration
ImagePullBackOffWrong image name or tag, or the registry needs an image pull secret
CrashLoopBackOffThe process exits at once: bad config, missing variable, failing liveness probe
OOMKilledThe memory limit is below what the application actually needs
Service has no endpointsThe selector does not match pod labels, or readiness never passes
EvictedNode under pressure; the pod exceeded its memory request
💡
Set a memory request and limit on every container. Without a request the scheduler is guessing, and without a limit one runaway pod can take the whole node down with it.

FAQ

How do I test a config change without breaking everything?
Watch the update with kubectl rollout status and revert with kubectl rollout undo. For bigger changes, deploy a second Deployment and shift the Service selector, or use weighted routing at the Ingress.
kubectl exec fails with 'container not found'?
The container is restarting or the pod is not running. Check kubectl get pods and read kubectl logs --previous first, since an interactive shell needs a live container.

Pods, Deployments and Services ConfigMaps, Secrets and probes

Last refreshed 2026-09-18.