如果健康检查不满足 successThreshold 和 failureThreshold,pods 的状态应该是什么?

What the status of pods should be if the health check doesn't meet successThreshold and failureThreshold, neither

从关于Configure liveness, readiness probes的K8S文档来看,假设successThresholdfailureThreshold的值有点大,探针不符合successThresholdfailureThreshold 同时在 pods 运行 一开始的时候, pods 应该是什么状态?

我猜你还没有完全理解 readiness 和 liveness probe。

准备情况调查

Readiness probes are designed to let Kubernetes know when your app is ready to serve traffic. Kubernetes makes sure the readiness probe passes before allowing a service to send traffic to the pod. If a readiness probe starts to fail, Kubernetes stops sending traffic to the pod until it passes.

同样根据官方 Kubernetes docs

If the readiness probe fails, the endpoints controller removes the Pod’s IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay is Failure. If a Container does not provide a readiness probe, the default state is Success.

例如,如果您的应用程序需要大约 15 秒才能正常工作,需要加载大量数据,您可以设置 readinessProbe。当您扩展部署或需要一段时间才能让 Pod 接收数据时,它会很有帮助。

对于就绪性探测,failureThreshold 值定义了从端点列表中删除 pod 之前探测必须失败的次数。

活性探测

Liveness probes let Kubernetes know if your app is alive or dead. If you app is alive, then Kubernetes leaves it alone. If your app is dead, Kubernetes removes the Pod and starts a new one to replace it.

简而言之,当您的应用程序 运行 时,Kubernetes 正在检查它是否可以访问某些共享的时间段,如果是,则它 returns 成功。如果不是,则将其计为失败并重试,直到探测到达 failureThreshold。达到这个值后,pod会重启。

===

基于 docs example.

readinessProbe 何时会成功:

readiness-exec   0/1   Pending   0     0s
readiness-exec   0/1   Pending   0     0s
readiness-exec   0/1   ContainerCreating   0     0s
readiness-exec   0/1   Running   0     8s
readiness-exec   1/1   Running   0     15s
readiness-exec   0/1   Completed   0     98s

readinessProbe 何时失败:

readiness-exec   0/1   Pending   0     0s
readiness-exec   0/1   Pending   0     0s
readiness-exec   0/1   ContainerCreating   0     0s
readiness-exec   0/1   Running   0     3s
readiness-exec   0/1   Completed   0     92s

它不会创建 pod,因为 readinessProbe 失败。在 pod 的描述中:

Warning  Unhealthy  2s (x12 over 57s)  kubelet, gke-default-pool-bc1968b0-1sh7  Readiness probe failed: cat: /tmp/healthyyyyy: No such file or directory

关于 livenessProbe 当它到达 failureThreshold 容器时将执行 RestartPolicy 中设置的内容。

由于探测器生成的信息存储在 kubelet 中,您可以描述 pod 以检查当前状态。如果你想获得更详细的信息,你必须使用 $ journalctl -u kubelet 就像 this case.

你可以在网上找到很多关于这个的文章。例如 google article or openshift article.

检查 this docs 信息,当使用探针时。

如果这没有回答,请编辑您的问题。