Kubernetes 启动探针当端点不可访问时

huangapple go评论60阅读模式
英文:

Kubernetes Startup probe when endpoint is not reachable

问题

我有以下部署配置。由于应用程序出现错误,test-worker-health 和 health 端点都无法访问。启动探针在失败后以 restartPolicy: Always 重新启动容器。Pod 进入 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
英文:

I have the following deployment config. The test-worker-health and health endpoints are both unreachable as the application is failing due to an error. The startup probe keeps restarting the container after failing as restartPolicy: Always. The pods enter CrashLoopBackoff state. Is there a way to fail such startup probe?

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

答案1

得分: 2

创业公司探针在失败后不断重新启动容器

启动探针并不会在失败后重新启动您的容器,但是 存活探针 (livenessProbe) 会这样做。

Pod 进入 CrashLoopBackoff 状态。有没有一种方法可以使这样的启动探针失败?

如果您删除 存活探针 (livenessProbe),则不会出现这种重新启动行为。您可能想使用 就绪探针 (readinessProbe) 代替吗?

有没有一种方法可以使这样的启动探针失败?

您是指什么?正如您所说,它已经在“失败”。您想要自动回滚吗?这可以通过例如金丝雀部署 (Canary Deployment) 来实现,但那是一个更高级的主题。

英文:

>The startup probe keeps restarting the container after failing

The startupProbe does not restart your container, but the livenessProbe does.

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

If you remove the livenessProbe, you will not get this restart-behavior. You may want to use a readinessProbe instead?

>Is there a way to fail such startup probe?

What do you mean? It is already "failing" as you say. You want automatic rollback? That is provided by e.g. Canary Deployment, but is a more advanced topic.

答案2

得分: 0

根据您的配置,startupProbe 将在启动后的 120 秒内尝试运行,如果在该时段内至少成功运行一次,则会在此后的失败阶段中失败。

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

我建议将 failureThreshold 增加,以便为您的应用程序提供足够的时间来完成启动。

英文:

According to your configuration, the startupProbe is tried within 120seconds after which it fails if it doesn't succeed atleast once during that period.

If your application requires more time to start up .i.e > 120seconds, then the startupProbe would keep restarting your application before it's booted up completely.

I'd suggest increasing the failureThreshold to afford your application sufficient time to boot-up.

huangapple
  • 本文由 发表于 2020年9月2日 01:21:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/63692552.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定