context deadline exceeded Kubernetes: meaning and how to fix it

context deadline exceeded is Go's timeout error and names no cause. Reproduced in probes, webhooks, Prometheus and etcd: find whose deadline fired.

Ben Gervais
Ben Gervais, Engineer at Arvo AILinkedInGitHub
Applies toAny Kubernetes error ending in context deadline exceeded: kubelet probes, admission webhooks, Prometheus scrapes, etcdctl, Helm, kubectl. Image pulls are covered because here they did not print the phrase at all. Not tested: CSI calls, pod sandbox creation, API server to etcd, kubeadm init
Verified onKubernetes server v1.37.0, kind v0.33.0, kubectl client v1.37.2, containerd v2.3.4, etcdctl 3.7.0, Prometheus 3.5.0, Helm v3.22.1, Docker Engine 28.0.4, Go 1.24.13, grpc-go v1.68.0, python:3.12-alpine, busybox:1.37, on a GitHub Actions runner, 2026-11-05
Lab folderscenarios/25-context-deadline-exceeded-callers, captured output in runs/search-2026-11-05/25-context-deadline-exceeded-callers

context deadline exceeded is the text of Go's context.DeadlineExceeded error: a caller set a time limit and it passed before the work finished. It says nothing about what was slow, and we got the identical message from a hung server, from an address that drops packets and from a webhook blocked by a NetworkPolicy. So the useful question is whose deadline fired: in Kubernetes that is usually the kubelet probing a pod (timeoutSeconds, default 1 s), the API server calling an admission webhook (timeoutSeconds, default 10 s) or Prometheus scraping a target (scrape_timeout, default 10 s). Then call the same endpoint from next to that caller with a longer wait: a steady answer above the deadline means the timeout is too low, and no answer means something is broken that a bigger timeout will not fix.

We reproduced each case below on a kind cluster and kept the literal output. The At a glance table is the short version.

At a glance

MessageWhose deadlineDefaultSettingFirst check
Readiness probe failed: Get "...": context deadline exceeded (Client.Timeout exceeded while awaiting headers) (or Liveness)kubelet1 stimeoutSeconds on the probecurl the probe path from a pod, with -m well above the timeout
failed calling webhook "...": failed to call webhook: Post "https://...?timeout=10s": context deadline exceededkube-apiserver10 s, range 1 to 30webhooks[].timeoutSecondsThe ?timeout= in the URL, then whether the API server can reach the webhook at all
Get "http://.../metrics": context deadline exceeded on the Prometheus targets pagePrometheus10 sscrape_timeoutscrape_duration_seconds for a target that sits exactly on the timeout
https://127.0.0.1:2379 is unhealthy: failed to commit proposal: context deadline exceededetcdctl5 s per command, 2 s dial--command-timeout, --dial-timeoutCertificates first: the same text appears when none are passed
Error: context deadline exceeded from helm --waitHelm5 min--timeoutkubectl get pods in the release namespace: Helm does not say which resource was not ready
Unable to connect to the server: context deadline exceededkubectlnone (0), but 32 s on API discovery--request-timeoutThe API server address and the route to it
rpc error: code = DeadlineExceeded desc = failed to pull and unpack imagecontainerd, not the kubelet30 s dial, 30 s response headersdial_timeout in hosts.toml; the header timeout is hard-codedRead the end of the message: it names the phase

What does context deadline exceeded mean?

It is one string from one Go variable. The context package defines DeadlineExceeded as "the error returned by Context.Err when the context is canceled due to its deadline passing". Everything else in the line was added by the program that hit it. We printed each Go timeout mechanism to see what the wrapping looks like (excerpt of repro-go/main.go; hang is a test server that sleeps 3 s, c is an http.Client with a 200 ms Timeout):

// 1. http.Client.Timeout, server sends no headers.
c := &http.Client{Timeout: 200 * time.Millisecond}
_, err := c.Get(hang.URL)
report("Client.Timeout, no headers", err)

// 3. Caller's context, no Client.Timeout.
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "GET", hang.URL, nil)
_, err = http.DefaultClient.Do(req)
report("context.WithTimeout, no headers", err)

// 4. net.Dialer.Timeout to an address that drops packets.
_, err = (&net.Dialer{Timeout: 200 * time.Millisecond}).Dial("tcp", "192.0.2.10:80")
report("net.Dialer.Timeout, dropped SYN", err)

The full program, on Go 1.24.13:

context.DeadlineExceeded.Error()   "context deadline exceeded"
Client.Timeout, no headers         Get "http://127.0.0.1:37773": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
                                   errors.Is(DeadlineExceeded)=true net.Error.Timeout=true
Client.Timeout, body stalls        context deadline exceeded (Client.Timeout or context cancellation while reading body)
                                   errors.Is(DeadlineExceeded)=true net.Error.Timeout=true
context.WithTimeout, no headers    Get "http://127.0.0.1:37773": context deadline exceeded
                                   errors.Is(DeadlineExceeded)=true net.Error.Timeout=true
net.Dialer.Timeout, dropped SYN    dial tcp 192.0.2.10:80: i/o timeout
                                   errors.Is(DeadlineExceeded)=true net.Error.Timeout=true
Client.Timeout, dropped SYN        Get "http://192.0.2.10/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
                                   errors.Is(DeadlineExceeded)=true net.Error.Timeout=true
gRPC call, context expires         rpc error: code = DeadlineExceeded desc = context deadline exceeded
                                   errors.Is(DeadlineExceeded)=false net.Error.Timeout=false

Three things in that output are worth keeping:

  • (Client.Timeout exceeded while awaiting headers) does not mean a server received the request. The dropped address never completed a TCP handshake and printed the same words as a server that was thinking. It means http.Client.Timeout fired before response headers arrived, for any reason.
  • The bracket tells you the mechanism. With it, the caller set http.Client.Timeout, as the kubelet's HTTP prober does. Without it, the caller passed a context with a deadline, as the webhook dispatcher and the Prometheus scrape loop do.
  • dial tcp ...: i/o timeout is the dial's own deadline. The dial tcp part narrows things down: no connection was made. (i/o timeout alone does not: Go prints it for a read deadline too.) errors.Is is true for it too, so code that branches on context.DeadlineExceeded treats them alike. The gRPC error is the opposite: same text, but errors.Is is false.

How do you find which caller it was, and how much is affected?

Read the line from the left, because the caller puts its own words first: Readiness probe failed, failed calling webhook, is unhealthy: failed to commit proposal. If you have only the bare phrase, list every recent warning that contains it:

kubectl get events -A --field-selector type=Warning | grep 'context deadline exceeded'

The OBJECT column gives the scope. One pod or one Deployment points at that workload. Pods on one node point at the node. Every namespace at once, or every write, points at a webhook or the control plane. For "since when", compare the oldest event with your last deploy or webhook change: events age out, after one hour by default (--event-ttl on the API server), so run this early.

What does the readiness or liveness probe message mean?

The kubelet gave up on the probe after timeoutSeconds, 1 s unless you set it. The Kubernetes API reference states "Defaults to 1 second. Minimum value is 1", and the lab pods with no setting that we described showed timeout=1s. We ran one pod for each probe type and fault. From kubectl -n deadline get events --field-selector reason=Unhealthy (trimmed to the timeout lines and reordered):

7s          Warning   Unhealthy   pod/http-slow-1s5            Readiness probe failed: Get "http://10.244.1.10:8080/sleep/1.5": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
7s          Warning   Unhealthy   pod/http-hung-timeout10      Readiness probe failed: Get "http://10.244.1.11:8080/sleep/600": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
7s          Warning   Unhealthy   pod/http-dropped-host        Readiness probe failed: Get "http://192.0.2.10:8080/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
1s          Warning   Unhealthy   pod/cpu-throttled            Readiness probe failed: Get "http://10.244.1.15:8080/cpu": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
30s         Warning   Unhealthy   pod/liveness-slow            Liveness probe failed: Get "http://10.244.2.26:8080/sleep/1.5": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
5s          Warning   Unhealthy   pod/tcp-dropped-host         Readiness probe failed: dial tcp 192.0.2.10:8080: i/o timeout
6s          Warning   Unhealthy   pod/exec-slow                Readiness probe failed: command timed out: "sleep 5" timed out after 1s
5s          Warning   Unhealthy   pod/grpc-silent              Readiness probe failed: timeout: failed to connect service "10.244.1.13:9000" within 1s: context deadline exceeded

Four different faults gave the same HTTP line: a path that takes 1.5 s, a path that never answers, an address that drops packets, and a container starved of CPU. The probe type changes the wording: an HTTP probe says context deadline exceeded, a TCP probe i/o timeout, an exec probe command timed out, and a gRPC probe to a port that never speaks gRPC timeout: failed to connect service. All of them are the same timeoutSeconds.

A failing readiness probe keeps the pod out of the Service. A failing liveness probe gets the container restarted: liveness-slow was answering every request, only 500 ms over the limit, and it had restarted once within 79 seconds of starting and 4 times by the end of the test. Other liveness failures, connection refused above all, are in the liveness probe runbook.

How do you tell a slow dependency from a timeout set too low?

Call the same path from a pod beside the caller, with a limit far above the deadline, and look at what comes back. Same pods as above:

kubectl -n deadline exec client -- curl -s -m 20 -o /dev/null \
  -w 'http=%{http_code} connect=%{time_connect} ttfb=%{time_starttransfer} total=%{time_total}\n' \
  http://<pod-ip>:8080/<probe-path>
http=200 connect=0.000561 ttfb=1.500959 total=1.500995
http=000 connect=0.000147 ttfb=0.000000 total=20.002384
http=000 connect=0.000000 ttfb=0.000000 total=5.002066

(trimmed: the commands. The first line was run with no -m, the third with -m 5.) They read as three different problems:

ResultMeaningWhat raising the timeout did
http=200, ttfb steady at 1.5 sAnswers, just above the deadline. The timeout is too low, or the handler is too slow for a health checktimeoutSeconds: 3 on the same path: pod Ready
http=000, connect is a number, total equals your -mConnected, no reply. The process is stuck, usually on its own dependencytimeoutSeconds: 10 on the hung path: still 0/1
http=000, connect=0.000000Never connected: dropped packets, a firewall or a wrong addressNothing to raise; fix the path

The fourth case is a 200 whose time depends on CPU rather than on the code. cpu-throttled and cpu-unthrottled run the same handler, which needs 150 ms of CPU. One has a 20m limit, the other 500m:

$ ten requests to cpu-throttled /cpu
200 8.526088
200 9.256885
200 8.353014
...
$ ten requests to cpu-unthrottled /cpu
200 0.319632
200 0.250523
200 0.257821
...

(trimmed: seven of each ten. All ten were 8.05 to 9.64 s and 0.25 to 0.32 s.) A pod at 8 seconds for 150 ms of work is not slow code. Confirm it inside the container:

kubectl exec <pod> -- cat /sys/fs/cgroup/cpu.stat
nr_periods 1914
nr_throttled 1699
throttled_usec 165228226

(trimmed to three lines, cpu-throttled, cgroup v2.) Do not treat nr_throttled as a yes or no answer: the 500m pod, which passed every probe, was throttled in 211 of its 391 periods too, because a 150 ms burst does not fit in one 50 ms quota window. throttled_usec against the request latency is the number that matters: 165 s here, 3.9 s there. kubectl top agrees only if you compare it with the limit: it showed 20m for the throttled pod, exactly its limit, which reads as a quiet pod.

What does failed calling webhook context deadline exceeded mean?

The API server called an admission webhook during your request and stopped waiting after the webhook's timeoutSeconds. The Kubernetes webhook docs set the default at 10 s and the range at 1 to 30 s, and the deadline is printed in the URL. A webhook behind a Service that accepts TLS and never answers:

$ kubectl -n wh-hang create configmap a --from-literal=k=v
error: failed to create configmap: Internal error occurred: failed calling webhook "hung.deadline.lab": failed to call webhook: Post "https://hook.webhook.svc:443/hang?timeout=10s": context deadline exceeded
[exit 1, elapsed 10.10s]

Each row below ran against the same kind of webhook configuration with failurePolicy: Fail unless noted (the default). Time is how long the whole kubectl command took:

Webhook statetimeoutSecondsResultTime
Hung processunsetcontext deadline exceeded10.10 s
Hung process3context deadline exceeded3.09 s
Answers in 5 s3context deadline exceeded3.10 s
Answers in 5 s8created5.11 s
Healthy, NetworkPolicy admits only pods in its namespace3context deadline exceeded3.09 s
URL webhook on an address that drops packets3context deadline exceeded3.10 s
Service with no endpointsunsetdial tcp 10.96.100.39:443: connect: connection refused0.09 s
Hung process, failurePolicy: Ignore3created, no error3.10 s

Three of those rows catch people out.

A dead webhook is not always a timeout. With a Service that selects no pods, the call was refused and the whole command took 0.09 s (0.10 s in the first run). That is on kind, where the API server dials the Service IP and nothing is behind it; other control planes and network plugins may fail differently. context deadline exceeded means something accepted or swallowed the connection and did not answer.

A webhook can be healthy for everyone except the API server. Here a NetworkPolicy allows ingress only from pods in the webhook's namespace, so traffic from the API server, on the host network, is dropped. From a pod in that namespace the same webhook answered in 9 milliseconds:

http=200 connect=0.001810 total=0.008628

So a curl from a pod clears the webhook and proves nothing about the API server's path. Compare the table above: if the backend answers quickly from a pod and the API server still times out, look at NetworkPolicy and, on managed clusters, the firewall between the control plane and the nodes. A related failure mode is in NetworkPolicy blocking traffic.

kubectl apply can succeed while nothing runs. When the webhook matches pods, the caller is the ReplicaSet controller, not you. kubectl create deployment returned success and no pod ever appeared:

NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/web   0/1     0            0           25s

NAME                             DESIRED   CURRENT   READY   AGE
replicaset.apps/web-745665747b   1         0         0       25s

The error is one level down, in kubectl describe rs:

  Warning  FailedCreate  1s (x8 over 22s)  replicaset-controller  Error creating: Internal error occurred: failed calling webhook "podhook.deadline.lab": failed to call webhook: Post "https://hook.webhook.svc:443/hang?timeout=3s": context deadline exceeded

The API server keeps count, and this is how you find a webhook without waiting for a user to report it:

kubectl get --raw /metrics | grep -E '^apiserver_admission_webhook_(rejection_count|fail_open_count)'
apiserver_admission_webhook_fail_open_count{name="hung-ignore.deadline.lab",type="validating"} 1
apiserver_admission_webhook_rejection_count{error_type="calling_webhook_error",name="hung.deadline.lab",operation="CREATE",rejection_code="503",type="validating"} 2
apiserver_admission_webhook_rejection_count{error_type="calling_webhook_error",name="podhook.deadline.lab",operation="CREATE",rejection_code="503",type="validating"} 11

(trimmed to three series.) The Ignore row is the quiet one. Every create in that namespace took an extra 3 seconds and whatever the webhook enforces was skipped, with no error to anyone. We saw two traces: that metric and an API server log line, Failed calling webhook, failing open hung-ignore.deadline.lab. The dispatcher source also writes a failed-open audit annotation, which we did not capture. Do not change failurePolicy to Ignore to clear this error on a webhook that enforces policy or security: you would turn a visible outage into a control that silently stopped working.

What does context deadline exceeded mean in Prometheus?

Prometheus gave up on the scrape after scrape_timeout, which defaults to 10 s and "cannot be greater than the scrape interval". We ran five jobs, four against one test server and one against an address that drops packets, with a 2 s global timeout and a 5 s interval. From /api/v1/targets (job, health, last scrape duration, timeout, last error):

dropped	down	2.000759949	2s	Get "http://192.0.2.10:9100/metrics": context deadline exceeded
fast	up	0.201809423	2s	
hung	down	4.000250611	4s	Get "http://dl-tgt:9100/s/600/metrics": context deadline exceeded
over	down	2.001052134	2s	Get "http://dl-tgt:9100/s/3/metrics": context deadline exceeded
over-raised	up	3.001650459	4s	

over and over-raised hit the same 3 s endpoint with different timeouts, so that one is a timeout too low and raising it to 4 s worked. hung got the same 4 s and still failed. A failed scrape records up 0 and a scrape_duration_seconds pinned on the timeout, which is how you spot it in a graph. With --enable-feature=extra-scrape-metrics on 3.5.0 you get the margin as well. Prometheus's current docs deprecate that flag in favour of the extra_scrape_metrics config option, which we did not run:

$ query: scrape_duration_seconds / scrape_timeout_seconds
fast	0.1009047115
dropped	1.0003799745
over-raised	0.75041261475
over	1.000526067
hung	1.00006265275

A value creeping toward 1 on a healthy target warns you before the scrape starts to fail. For a real /metrics endpoint the usual slow cause is too many series, which is worth fixing on the target rather than by raising the timeout.

Why does kubectl say context deadline exceeded?

Because a limit on the client ran out, and you may not have set it. kubectl's --request-timeout defaults to 0, which its flag help describes as no timeout, but API discovery has its own 32 s, the defaultTimeout in client-go, which you can see as ?timeout=32s in kubectl's retry lines. A webhook's deadline also reaches kubectl as this text, from the server side. We pointed a kubeconfig at an address that drops packets and tried both:

$ env KUBECONFIG=/tmp/tmp.33myyU0Sjn kubectl get pods --request-timeout=3s
...
Unable to connect to the server: context deadline exceeded
[exit 1, elapsed 15.12s]

$ env KUBECONFIG=/tmp/tmp.33myyU0Sjn kubectl get pods --request-timeout=0 --v=0 --insecure-skip-tls-verify=false
...
Unable to connect to the server: dial tcp 192.0.2.10:6443: i/o timeout
[exit 1, elapsed 150.10s]

(trimmed: five retry lines each.) Same fault, different words, because a different deadline fired first. With 3 s, kubectl's retries took 15 s in total. Without it, the dial's own 30 s limit fired five times, ahead of discovery's 32 s. We did not test a server that accepts the connection and then stalls, which is where the 32 s would fire. The retry lines in the first command mixed context deadline exceeded with net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers), and --request-timeout=1ms against a healthy cluster printed one in our first run and the other in the second. Do not grep your alerts for one exact spelling.

kubectl wait and kubectl rollout status use their own timer and word it differently: timed out waiting for the condition.

Why does etcdctl say context deadline exceeded?

Check TLS first: in our test etcd was healthy and the handshake failed. Run with no certificate flags on a healthy kubeadm-style control plane:

$ kubectl -n kube-system exec pod/etcd-aurora-lab-control-plane -- etcdctl --endpoints=https://127.0.0.1:2379 --command-timeout=2s endpoint health
...
https://127.0.0.1:2379 is unhealthy: failed to commit proposal: context deadline exceeded
Error: unhealthy cluster

The word unhealthy is wrong, and the real reason is on the warning line above it, which we trimmed from that block. Without --cacert, etcdctl does not trust the server's certificate:

"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: connection error: desc = \"transport: authentication handshake failed: tls: failed to verify certificate: x509: certificate signed by unknown authority\""}

With the certificates, the same endpoint answers at once:

kubectl -n kube-system exec <etcd-pod> -- etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key endpoint health
https://127.0.0.1:2379 is healthy: successfully committed proposal: took = 7.77497ms

etcdctl retries the handshake failure until --command-timeout (default 5 s, --dial-timeout 2 s) expires, so a certificate problem comes out as a timeout. Rule that out before you touch disks or quorum. An address that drops packets gives the same failed to commit proposal line.

Does an image pull fail with context deadline exceeded?

Not with the literal phrase in our tests on containerd 2.3.4: the gRPC code says DeadlineExceeded and the text says something else. The kubelet does not put a deadline on pulls: runtimeRequestTimeout (2 min, confirmed from /configz on our node) covers "all runtime requests except long running requests - pull, logs, exec and attach", and the CRI client calls PullImage with a cancel context. The limits are containerd's. Three broken registries, none of which printed the literal phrase:

RegistryTime per pullEvent on the pod (trimmed)
Address drops packets30.06 srpc error: code = DeadlineExceeded desc = failed to pull and unpack image ... dial tcp 192.0.2.10:5000: i/o timeout
Accepts, never answers60.07 srpc error: code = DeadlineExceeded desc = failed to pull and unpack image ... net/http: timeout awaiting response headers
Serves the manifest, stalls in the layer5 minrpc error: code = Canceled desc = failed to pull and unpack image "172.18.0.6:5001/lab/app:1": context canceled

The first two are containerd's dial_timeout (default 30 s, settable per registry in hosts.toml) and its ResponseHeaderTimeout of 30 s, tried twice. The third is image_pull_progress_timeout, 5m0s in our dumped config, and containerd logged it plainly: cancel pulling image 172.18.0.6:5001/lab/app:1 because of no progress in 5m0s. So a pull that dies at 5 minutes with context canceled is a stalled transfer. The 30.06 s and 60.07 s are from crictl pull on the node, which reproduced the first two without the kubelet in the path; the 5 minutes is containerd's own count. The stalled layer has one result: in the first run that registry refused connections.

The literal phrase does appear in other clients. Microsoft documents Get "https://<container-registry-name>.azurecr.io/v2/": context deadline exceeded for Azure Container Registry and attributes it to DNS. We did not reproduce that one. For the pod-level symptom, see ImagePullBackOff.

Docker, Helm and CI: is it the same error?

Yes in meaning, with each tool's own deadline.

  • Helm. helm upgrade --install --wait --timeout 20s on a Deployment whose readiness never passes printed Error: context deadline exceeded after 20.63 s, and nothing about which resource. The default is 5m0s from helm install --help. The release was left STATUS: failed with the pod at 0/1: read the pods, then decide. Raising --timeout helps only a rollout that was going to finish.
  • Docker. On Engine 28.0.4, docker pull from an address that drops packets gave net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) after 15.02 s, which matches the 15 s client in PingV2Registry. A listener that never spoke TLS gave net/http: TLS handshake timeout in our first run, after 10.03 s. In the second run that listener was refused in 0.02 s, which we put down to it not being up yet, so this one has a single result.
  • GitLab Runner. On the Kubernetes executor, GitLab's docs say these errors "usually indicate that the Kubernetes API client hit a timeout for a given cluster API request" and point at kube-apiserver metrics. We did not reproduce this.

How do you fix it?

Find the caller, run the side-by-side check, then fix what it shows:

FindingFixRisk and rollback
Health path calls a dependencyMake liveness check only the process. Time-box any dependency checkNeeds a rollout. Roll back with kubectl rollout undo
Container throttledRaise the CPU limit, or remove itRestarts pods on rollout and uses more of the node; revert the value
Webhook backend hungRestart or fix the backend; give it more than one replicaRestart risk only. While it is down, every matched write fails
API server cannot reach webhookAllow the control plane in the NetworkPolicy or firewallWidens access to one port; revert the rule
Registry or target unreachableFix the route, DNS or addressDepends on the change
Steady latency just above the deadlineRaise the timeout (next section)Slower failure detection; revert the value

We tested the first row on the lab scenario; it is at the end of this page.

When is raising the timeout the right fix?

When all three are true: the endpoint answers every time, its latency is steady across several calls, and that latency is what you expect for the work it does. In our runs that was the 1.5 s probe with timeoutSeconds: 3, the 3 s scrape with scrape_timeout: 4s and the 5 s webhook with timeoutSeconds: 8.

Set it above the worst normal latency, not to the maximum, and know what it costs. The webhook passed, but every create in those namespaces now takes 5.11 s, and the good practices page says webhooks should evaluate "typically in milliseconds". A longer liveness timeout means a truly stuck container is detected later. A 5 s webhook needs a faster webhook; the timeout buys you time to get there.

Raising it is wrong whenever the answer never comes. We tested this on the scenario below, and on the hung target and the hung probe above: more waiting produced the same message, later. The same reasoning for nginx, where proxy_read_timeout is the tempting knob, is in the 504 Gateway Timeout runbook.

How do you verify the fix?

Pass conditions, by caller. Watch each for at least 10 minutes, or one full deploy for a webhook:

  • Probe: pod 1/1, RESTARTS flat, no new Unhealthy events: kubectl get events --field-selector reason=Unhealthy.
  • Webhook: the failing command succeeds, in about the backend's real latency, and apiserver_admission_webhook_rejection_count and fail_open_count stop rising.
  • Prometheus: up is 1 and scrape_duration_seconds / scrape_timeout_seconds sits well under 1.
  • etcd: etcdctl endpoint health with certificates reports successfully committed proposal.

How do you prevent it?

The metric names below come from our captured output. We ran the scrape ratio by hand without the threshold, and did not run the two increase() expressions or deploy any of them as alert rules, so treat the thresholds as starting points:

increase(apiserver_admission_webhook_rejection_count{error_type="calling_webhook_error"}[5m]) > 0
increase(apiserver_admission_webhook_fail_open_count[5m]) > 0
scrape_duration_seconds / scrape_timeout_seconds > 0.8

The second one is the one most clusters lack, since a failing-open webhook is otherwise silent. Keep /healthz free of dependency calls and review it like production code, because in our scenario one added line stalled a rollout. In your load test, record the health path's latency at your CPU limit: if it is near timeoutSeconds under load, you have found the next incident. Scope each webhook's namespaceSelector and rules to what it needs.

Common mistakes

  • Searching for the phrase. It has no single cause. Search for the words in front of it: the first thing on the line is the caller.
  • Treating awaiting headers as proof that the server received the request. The dropped address printed it too.
  • Testing a webhook from a pod. The caller is the API server, on a different network path. In our run a pod in the webhook's namespace got 200 in 9 ms while the API server timed out.
  • Reading unhealthy from etcdctl literally. Check the certificates first.
  • Setting failurePolicy: Ignore to make the error go away. It does, and the control stops working silently.
  • Raising timeoutSeconds on a hung path. It failed at 10 s just as at 1 s, more slowly.

What we saw in the lab

Scenario 25 applies the probe case to the lab's shop app: a three-node kind cluster, with nginx -> api -> redis. An api release adds a stock lookup to /healthz, with no timeout, against an address that drops packets. ./lab.sh selftest passed after we fixed a bug in our first break.sh, which left that first run with an unbroken app (selftest: 1 passed, 0 failed on the second). The sections above ran as extra steps of the same job, in their own namespaces or containers. The check requires the deadline message in events plus a stuck rollout with old pods still available.

New pods never got Ready and the old ones kept serving, so the frontend still returned 200. The visible symptom was a rollout that did not finish:

NAME                   READY   STATUS    RESTARTS   AGE
api-68db95c8ff-gvwvw   0/1     Running   0          50s
api-f64486c4c-6rpjr    1/1     Running   0          58s
api-f64486c4c-8f5mc    1/1     Running   0          58s
  Warning  Unhealthy  15s (x3 over 35s)  kubelet            spec.containers{api}: Liveness probe failed: Get "http://10.244.2.18:8080/healthz": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
  Normal   Killing    15s                kubelet            spec.containers{api}: Container api failed liveness probe, will be restarted
  Warning  Unhealthy  3s (x12 over 54s)  kubelet            spec.containers{api}: Readiness probe failed: Get "http://10.244.2.18:8080/healthz": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

(trimmed to three events from kubectl describe pod.) kubectl describe gives the deadline: Readiness: http-get http://:8080/healthz delay=0s timeout=1s period=5s. A wget -T 20 from another pod got no answer in 15.02 s (wget: error getting response), so this was not a 1 s problem. We believe the connection ended when the kubelet finished killing that container, but we did not capture that directly.

Then we applied the tempting fix, timeoutSeconds: 10 on both probes. Ninety seconds later the new pod was on its first restart and failing the same way:

NAME                   READY   STATUS    RESTARTS      AGE
api-55c98bcdcf-d4bvd   0/1     Running   1 (10s ago)   90s
api-f64486c4c-6rpjr    1/1     Running   0             2m53s
api-f64486c4c-8f5mc    1/1     Running   0             2m53s
4s          Warning   Unhealthy   pod/api-55c98bcdcf-d4bvd        Readiness probe failed: Get "http://10.244.2.19:8080/healthz": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

(trimmed: the last of four lines. The other three were connection refused, EOF and connection reset by peer, 15 s old.)

Waiting for deployment "api" rollout to finish: 1 out of 2 new replicas have been updated...
error: timed out waiting for the condition

The real fix was removing the line. We put timeoutSeconds back to 1, took the call out of /healthz and restarted:

deployment "api" successfully rolled out

/healthz then answered in real 0m 0.00s with {"status": "ok"}, at the original 1 s timeout.

What surprised us: the literal phrase never appeared on image pulls, the 1 ms kubectl test gave a different string in each of two runs, and nr_throttled was high on the pod that was fine. The numbers on this page are from the second run. Run 1 is kept next to it, with its failed selftest, and it is the only source of the Docker TLS line and the context deadline exceeded result of the 1 ms test. Most cases ran twice, each run on one GitHub runner; the app scenario's fault, the stalled layer and the crictl pull from the dropped address ran once. So the timings show the mechanism and are not a benchmark.

The Aurora, HolmesGPT and K8sGPT investigations have not been run on this scenario, so there is no trace or verdict for any of them here.

How Aurora handles this

Aurora receives the alert and investigates with read-only kubectl under its default observability_only command policy, choosing the commands itself. For this error it would need the evidence on this page: events, the probe spec, and a direct call to the path. Two limits we already know from other scenarios: that policy denies the whole rollout verb, read-only subcommands included, and it blocked exec in three graded lab runs, so it may not be able to run the side-by-side curl. It records every tool call and its output, cites them in the report and lists suggested fixes separately. Mutating commands are blocked by default, so it proposes the change rather than applying it. Its results on other scenarios are on the benchmark.

Related: liveness probe failed, 504 Gateway Timeout in nginx, ImagePullBackOff, NetworkPolicy blocking traffic, Service has no endpoints, paste your kubectl output into the diagnoser, and the root cause analysis guide for SREs.

Sources and verification

Questions

Other runbooks