无法访问端点时的 Kubernetes 启动探测

Kubernetes Startup probe when endpoint is not reachable

我有以下部署配置。 test-worker-health 和 health 端点都无法访问,因为应用程序因错误而失败。启动探测在失败后不断重启容器,因为 restartPolicy: Always。 pods进入CrashLoopBackoff状态。有没有办法让这样的启动探测失败?

livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: 8080
          periodSeconds: 20
          successThreshold: 1
          timeoutSeconds: 30
startupProbe:
          httpGet:
            path: /test-worker-health
            port: 8080
          failureThreshold: 12
          periodSeconds: 10

The startup probe keeps restarting the container after failing

startupProbe 不会重启您的容器,但 livenessProbe 会。

The pods enter CrashLoopBackoff state. Is there a way to fail such startup probe?

如果删除 livenessProbe,您将不会得到此 restart-behavior。您可能想改用 readinessProbe

Is there a way to fail such startup probe?

你是什么意思?正如您所说,它已经“失败”了。你想要自动回滚?这是由例如提供的。金丝雀部署,但是是一个更高级的主题。

根据您的配置,startupProbe 会在 120 秒内尝试,如果在此期间至少没有成功一次,它就会失败。

如果您的应用程序需要更多时间来启动,即 > 120 秒,则 startupProbe 会在您的应用程序完全启动之前继续重新启动它。

我建议增加 failureThreshold 以使您的应用程序有足够的时间 boot-up。