kubernetes pod 的探测失败 - 等待标头时超出 Client.Timeout

Jov*_*ing 12 kubernetes

我已经搜索过,但没有任何东西可以帮助我度过难关。

我的套装。
k8s-v1.20.2。
印花布 - 3.16.6。
pod-cidr = 10.214.0.0/16。
服务-cidr = 10.215.0.1/16。

由 kubespray 使用此安装https://kubernetes.io/ko/docs/setup/product-environment/tools/kubespray

pod 一次又一次重新启动
ingress-nginx-controller pod 描述

[dns-autoscaler pod 日志]

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
Run Code Online (Sandbox Code Playgroud)

[dns-autoscaler pod 描述]

kubelet  Readiness probe failed: Get "http://10.214.116.129:8080/healthz": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Run Code Online (Sandbox Code Playgroud)

[coredns pod 日志]

pkg/mod/k8s.io/client-go@v0.18.3/tools/cache/reflector.go:125: Failed to list *v1.Namespace: Get "https://10.215.0.1:443/api/v1/namespaces?limit=500&resourceVersion=0": dial tcp 10.215.0.1:443: i/o timeout
Run Code Online (Sandbox Code Playgroud)

[coredns pod 描述]

Get "http://10.214.122.1:8080/health": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Run Code Online (Sandbox Code Playgroud)

我尝试安装 ingress-nginx-controller 它得到了我的日志和描述。
[入口控制器日志]

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:
Run Code Online (Sandbox Code Playgroud)

[入口控制器描述]

Liveness probe failed: Get "https://10.214.233.2:8443/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Run Code Online (Sandbox Code Playgroud)

所有这些 Pod 都在与 Readiness/Liveness 探测失败作斗争:获取“http://10.214.116.155:10254/healthz”:超出上下文截止日期(等待标头时超出 Client.Timeout)。

印花布正在奔跑。我检查了 Pod 到 Pod 的通信(正常)。
印花布正在运行

[kubectl 获取组件状态]

controller-manager   Unhealthy   Get "http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused
scheduler            Unhealthy   Get "http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused
etcd-1               Healthy     {"health":"true"}
etcd-2               Healthy     {"health":"true"}
etcd-0               Healthy     {"health":"true"}
Run Code Online (Sandbox Code Playgroud)

kubectl get componentstatuses 我遵循了如何解决 Kubernetes 中的调度程序和控制器管理器不健康状态 ,现在调度程序和控制器管理器是健康的。

[kubectl 获取节点]

Nodes are ready.
Run Code Online (Sandbox Code Playgroud)

我做错了什么?TT
提前致谢

Pro*_*ton 14

将应用程序部署到 Kubernetes 时遇到此问题。

警告不健康 10m(x3206 超过 3d16h)kubelet Liveness 探测失败:获取“http://10.2.0.97:80/”:超出上下文截止时间(等待标头时超出 Client.Timeout)

我在 pod 中执行了一个 exec:

kubectl exec <pod-name> -it --namespace default /bin/bash
Run Code Online (Sandbox Code Playgroud)

然后我对 pod 的 IP 和端口运行了一个curl 请求:

curl 10.2.0.97:80
Run Code Online (Sandbox Code Playgroud)

它返回了成功的响应。但活性探测仍然未能成功执行。

我是这样解决的:

我所要做的就是timeoutSeconds增加到10

livenessProbe:
  httpGet:
    path: /
    port: http
  initialDelaySeconds: 300       
  periodSeconds: 20
  timeoutSeconds: 10
Run Code Online (Sandbox Code Playgroud)

之后,活性探针开始成功执行

可以对就绪探针执行相同的操作:

ReadinessProbe:
  httpGet:
    path: /
    port: http
  initialDelaySeconds: 30
  periodSeconds: 20
  timeoutSeconds: 10
Run Code Online (Sandbox Code Playgroud)

参考有时,Liveness/Readiness Probes 因 net/http 而失败:等待连接时取消请求(等待 head 时超出了 Client.Timeout)