Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

kubectl: error: timed out waiting for the condition

The wait command only reports that a condition never became true. Read pod events, probes and scheduling, fix the cause, then wait again.

~5 min readKubernetes
#kubernetes#kubectl#deployments#troubleshooting
Bold white headline reading TIMED OUT beside a cyan Deployment crate behind an amber condition gate.

Introduction & Quick Summary

A deploy pipeline stops on a line that says nothing about the app:

error: timed out waiting for the condition

It comes from kubectl wait, kubectl rollout status, helm upgrade --wait or a CI step wrapped around one of them. Quick answer: the condition the command was waiting for never became true within the timeout, so the command gave up. The timeout is not the problem; the workload never reached the requested state.

bash
kubectl wait --for=condition=available deployment/api --timeout=300s kubectl rollout status deployment/api --timeout=300s kubectl get deploy api -o wide kubectl describe deploy api | sed -n '/Conditions/,$p'

Read the workload before raising the timeout. A Deployment that reports Available=False with MinimumReplicasUnavailable is usually waiting on a readiness probe, a missing image, an unschedulable pod or a quota. This guide covers what each wait command actually checks, how to find the blocking condition in seconds, and how to write a CI step that fails with evidence instead of a bare timeout.

Core Mechanics, Signatures & Reproducible Setup

kubectl wait polls a resource's .status.conditions array and returns when a condition with the requested type has status: "True". --for=delete and --for=jsonpath=... are the other supported forms.

bash
kubectl wait --for=condition=Ready pod/api-7d9f-abc --timeout=120s kubectl wait --for=delete pod/api-7d9f-abc --timeout=120s kubectl wait --for=jsonpath='{.status.loadBalancer.ingress[0].ip}' svc/api --timeout=180s

Reproduce locally with kind:

bash
kind create cluster --name wait-demo kubectl create deployment api --image=nginx:1.27 --replicas=2 kubectl set env deployment/api BREAK=1 kubectl patch deployment api -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx","readinessProbe":{"httpGet":{"path":"/healthz","port":80},"initialDelaySeconds":5,"periodSeconds":5}}]}}}}' kubectl wait --for=condition=available deployment/api --timeout=60s # error: timed out waiting for the condition

The Deployment never reports Available=True because /healthz returns 404, so the pods never become Ready, so availableReplicas stays at 0.

CommandWatchesFails fast on
kubectl wait --for=condition=Available deploy/xDeployment conditionstimeout only
kubectl rollout status deploy/xrollout progress, prints "Waiting for ..."ProgressDeadlineExceeded
helm upgrade --waitall resources in the releasetimeout or failed hook
kubectl wait --for=condition=Ready pod/xpod readinesstimeout only
kubectl wait --for=condition=Complete job/xjob completiontimeout only
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/xany status fieldtimeout only
ResourceUseful conditionMeaning when False
DeploymentAvailablefewer than minimum replicas ready
DeploymentProgressingProgressDeadlineExceeded, rollout stalled
PodReadyreadiness probe failing or container not started
PodContainersReadyone or more containers unready
JobCompletestill running, or Failed
PersistentVolumeClaimstatus.phase=Boundno matching PV or StorageClass
Custom resourcewhatever the operator definesread the CRD's printer columns

Key Comparison Table

What you seeRoot causeFirst command
Available=False MinimumReplicasUnavailablepods not Readykubectl get pods -o wide
Progressing=False ProgressDeadlineExceededrollout stalled past deadlinekubectl describe deploy events
Pods Pendingunschedulable: CPU, memory, taints, PVCkubectl describe pod last line
Pods ImagePullBackOffwrong tag, private registry authkubectl describe pod events
Pods CrashLoopBackOffcontainer exits during startkubectl logs --previous
0/2 ready with restarts 0readiness probe path or port wrongkubectl exec -- curl localhost:PORT/healthz
PVC Pendingno StorageClass, no PV, wrong access modekubectl describe pvc
Service with no endpointsselector mismatchkubectl get endpoints svc/x
Wait flagCorrect useCommon mistake
--timeout=300sexplicit durationwriting --timeout=300 which means 300 seconds but reads as nanoseconds in some older docs
--timeout=0wait forever, default is 30susing it in CI and hanging the job
-n prodtarget namespaceforgetting it and waiting in default
--allevery object of that typewaiting on unrelated broken resources
--for=condition=Readyexact type name, case sensitiveready or Available on a Pod

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Deployment Available never becomes true

bash
kubectl get deploy api -o jsonpath='{.status.conditions[*].type}={.status.conditions[*].status}{"\n"}' kubectl get pods -l app=api -o wide kubectl describe pod -l app=api | tail -25

Three causes cover most cases: the image cannot be pulled, the pod cannot be scheduled, or the readiness probe fails. The probe case is the quiet one, because the container is running and the logs look healthy while READY 0/1 never changes.

readinessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 10 periodSeconds: 5 failureThreshold: 3

Check the port the app really listens on, and whether /healthz answers before the app finishes loading. A probe that hits a path behind authentication always returns 401 and never passes.

2. rollout status versus wait

kubectl rollout status understands the rollout state machine and prints progress; it exits non-zero when the Deployment reports ProgressDeadlineExceeded, which is often earlier than your timeout. kubectl wait only sees the condition and the clock.

bash
kubectl rollout status deploy/api --timeout=300s # Waiting for deployment "api" rollout to finish: 0 of 2 updated replicas are available... # error: deployment "api" exceeded its progress deadline

In CI, prefer rollout status for Deployments and wait for objects without a rollout concept.

3. PVC binding

bash
kubectl get pvc data -o jsonpath='{.status.phase}{"\n"}' kubectl describe pvc data | tail -15

Pending with WaitForFirstConsumer is normal until a pod schedules; with Immediate it means no PV satisfies the request. Access mode mismatches and a missing storageClassName also keep it Pending, and a stateful workload then waits forever on its own condition.

4. Jobs and custom resources

bash
kubectl wait --for=condition=Complete job/migrate --timeout=600s kubectl get job migrate -o yaml | yq '.status'

A Job whose pod is stuck in ImagePullBackOff never completes, and backoffLimit only applies to failed runs, not to unschedulable ones. For operators, check kubectl get crd <name> -o jsonpath='{.status.conditions}' and the operator logs; a CR whose condition stays Unknown usually means the controller is not running.

5. Timeout and context traps

bash
# waits in the wrong namespace and times out for the wrong reason kubectl wait --for=condition=available deploy/api --timeout=120s # correct kubectl wait --for=condition=available deploy/api -n prod --timeout=120s

kubectl wait requires the resource to exist. If the manifest was never applied, the command fails with not found rather than a timeout, which is a useful distinction when reading CI logs. --for=jsonpath needs Kubernetes 1.23 or newer and a value that compares as a string.

6. Make CI fail with evidence

bash
if ! kubectl rollout status deploy/api --timeout=300s; then kubectl get pods -o wide kubectl describe deploy api | tail -30 kubectl get events --sort-by=.lastTimestamp | tail -25 exit 1 fi

This turns a one-line timeout into the pod state, the events and the condition that blocked the rollout. kubectl get events --field-selector involvedObject.name=api narrows it further. Use the YAML formatter to validate the manifest before applying, and the JSON formatter when reading -o json output in a script.

Common Compilation/Runtime Mistakes & Version Gotchas

  • Raising the timeout first. A condition that is never going to be true will not become true in ten minutes either; the extra time only delays the failure.
  • Waiting on the Deployment when the pod is the problem. Available is a summary. The pod's Ready condition and events carry the reason.
  • Wrong condition name. Ready for pods, Available and Progressing for Deployments, Complete for Jobs; names are case-sensitive and an unknown type simply never matches.
  • Namespace drift. A missing -n waits in default, finds nothing or finds a stale object, and times out.
  • --all in shared clusters. It waits on resources other teams own and turns their incident into your failed build.
  • Helm --wait without --timeout. The default is 5 minutes, and a rollout that legitimately takes longer fails the release and can trigger a rollback.
  • Version differences. kubectl wait gained --for=jsonpath and --for=create over several releases; clusters older than 1.23 reject those flags. Helm 3.14 changed how failed hooks interact with --wait, so pin the Helm version in CI.
  • ProgressDeadlineExceeded is sticky. Once a Deployment reports it, a later successful rollout clears it, but a Deployment left in that state keeps reporting it until the spec changes; restarting pods by hand does not reset the condition.

The reliable pattern is: wait on the most specific condition that represents user-visible readiness, print the pod state and events when the wait fails, and fix the underlying scheduling, probe or image problem that keeps the condition false.

Official documentation: kubectl wait and Deployments.

Official references

primary documentation

The Kubernetes documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Kubernetes work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Kubernetes guides

More in Kubernetes

All Kubernetes guides

The guides filed next to this one in Kubernetes, in library order.