Kubernetes 健康检查:timeoutSeconds 超过 periodSeconds

问题描述

在 Kubernetes Kubernetes Health Check Probes 中,如果 timeoutSeconds 超过 periodSeconds 会发生什么?例如:

initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 10
successthreshold: 1
failureThreshold: 3

Pod 什么时候会“失败”?

  • initialDelaySeconds + (periodSeconds * failureThreshold);或
  • initialDelaySeconds + ( MAX(periodSeconds,timeoutSeconds) * failureThreshold);

同样的问题适用于 Pod 成功的情况。

解决方法

blog post 中有一张图表清楚地说明了您的问题:

Probe Timeline

pod 将在最低重启,

time = initialDelay + (failureThreshold - 1) * period + timeout

  • timeoutSeconds > periodSeconds ?

探测调用将以给定的时间间隔触发,与之前的探测响应无关。一旦探测调用通过或失败/超时,将检查 failureThreshold。但建议使用大于 periodSecondstimeoutSeconds