<p>I've searched but nothing has helped me through.</p>
<p>My Set.<br />
k8s - v1.20.2.<br />
calico - 3.16.6.<br />
pod-cidr = 10.214.0.0/16.<br />
service-cidr = 10.215.0.1/16.</p>
<p>Installed by kubespray with this one <a href="https://kubernetes.io/ko/docs/setup/production-environment/tools/kubespray" rel="noreferrer">https://kubernetes.io/ko/docs/setup/production-environment/tools/kubespray</a></p>
<p><a href="https://i.stack.imgur.com/5w7WH.png" rel="noreferrer">pod restarts again and again</a>.<br />
<a href="https://i.stack.imgur.com/ABvUf.png" rel="noreferrer">ingress-nginx-controller pod describe</a></p>
<p>[dns-autoscaler pod logs]</p>
<pre><code>github.com/kubernetes-incubator/cluster-proportional-autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:96: Failed to list *v1.Node: Get https://10.215.0.1:443/api/v1/nodes: dial tcp 10.215.0.1:443: i/o timeout
</code></pre>
<p>[dns-autoscaler pod describe]</p>
<pre><code>kubelet  Readiness probe failed: Get &quot;http://10.214.116.129:8080/healthz&quot;: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
</code></pre>
<p>[coredns pod logs]</p>
<pre><code>pkg/mod/k8s.io/client-go@v0.18.3/tools/cache/reflector.go:125: Failed to list *v1.Namespace: Get &quot;https://10.215.0.1:443/api/v1/namespaces?limit=500&amp;resourceVersion=0&quot;: dial tcp 10.215.0.1:443: i/o timeout
</code></pre>
<p>[coredns pod describe]</p>
<pre><code>Get &quot;http://10.214.122.1:8080/health&quot;: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
</code></pre>
<p>And I tried to install ingress-nginx-controller it got me logs and describe.<br />
[ingress-controller logs]</p>
<pre><code>W0106 04:17:16.715661       6 flags.go:243] SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)
W0106 04:17:16.715911       6 client_config.go:541] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0106 04:17:16.716200       6 main.go:182] Creating API client for https://10.215.0.1:
</code></pre>
<p>[ingress-controller describe]</p>
<pre><code>Liveness probe failed: Get &quot;https://10.214.233.2:8443/&quot;: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

</code></pre>
<p>All those pods are struggling with Readiness/Liveness probe failed: Get &quot;http://10.214.116.155:10254/healthz&quot;: context deadline exceeded (Client.Timeout exceeded while awaiting headers).</p>
<p>Calico is Running. and i checked pod to pod communication(OK).<br />
<a href="https://i.stack.imgur.com/ir5w3.png" rel="noreferrer">calico is Running</a></p>
<p>[kubectl get componentstatuses]</p>
<pre><code>controller-manager   Unhealthy   Get &quot;http://127.0.0.1:10252/healthz&quot;: dial tcp 127.0.0.1:10252: connect: connection refused
scheduler            Unhealthy   Get &quot;http://127.0.0.1:10251/healthz&quot;: dial tcp 127.0.0.1:10251: connect: connection refused
etcd-1               Healthy     {&quot;health&quot;:&quot;true&quot;}
etcd-2               Healthy     {&quot;health&quot;:&quot;true&quot;}
etcd-0               Healthy     {&quot;health&quot;:&quot;true&quot;}
</code></pre>
<p><a href="https://i.stack.imgur.com/dtoJ3.png" rel="noreferrer">kubectl get componentstatuses</a>
I followed <a href="https://stackoverflow.com/questions/64296491/how-to-resolve-scheduler-and-controller-manager-unhealthy-state-in-kubernetes">How to resolve scheduler and controller-manager unhealthy state in Kubernetes</a>
and now scheduler and controller-manager are healthy.</p>
<p>[kubectl get nodes]</p>
<pre><code>Nodes are ready.
</code></pre>
<p>what i did wrong? T.T.<br />
thanks in advance</p>

<p>Experienced this issue when deploying an app to Kubernetes.</p>
<blockquote>
<p>Warning  Unhealthy  10m (x3206 over 3d16h)    kubelet  Liveness probe failed: Get &quot;http://10.2.0.97:80/&quot;: context deadline exceeded (Client.Timeout exceeded while awaiting headers)</p>
</blockquote>
<p>I did an exec into the pod:</p>
<pre><code>kubectl exec &lt;pod-name&gt; -it --namespace default /bin/bash
</code></pre>
<p>And then I ran a curl request to the IP and port of the pod:</p>
<pre><code>curl 10.2.0.97:80
</code></pre>
<p>And it returned a successful response. But the liveness probe was still failing to execute successfully.</p>
<p><strong>Here's how I solved it:</strong></p>
<p>All I had to do was to increase the <code>timeoutSeconds</code> to <code>10</code>:</p>
<pre><code>livenessProbe:
  httpGet:
    path: /
    port: http
  initialDelaySeconds: 300       
  periodSeconds: 20
  timeoutSeconds: 10
</code></pre>
<p>After which the liveness probe started executing successfully</p>
<p>Same can be done for the readiness probe:</p>
<pre><code>ReadinessProbe:
  httpGet:
    path: /
    port: http
  initialDelaySeconds: 30
  periodSeconds: 20
  timeoutSeconds: 10
</code></pre>
<p><strong>Reference</strong>: <a href="https://github.com/kubernetes/kubernetes/issues/89898#issuecomment-1028654403" rel="noreferrer">Sometime Liveness/Readiness Probes fail because of net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting head</a></p>
