首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >春引导服务的k8s探测,最佳实践

春引导服务的k8s探测,最佳实践
EN

Stack Overflow用户
提问于 2022-06-01 20:39:31
回答 2查看 476关注 0票数 0

我正在为为spring引导服务服务的kubernetes部署配置启动/活性/就绪探测。在春季引导文档中,最佳实践是使用相应的活跃度&就绪执行器端点,如下所述:https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot

你用什么做你的启动探针?您对failureThreshold、延迟、期间和超时值的建议是什么?在向现有设置部署isito侧雷达时,遇到了问题吗?

EN

回答 2

Stack Overflow用户

发布于 2022-06-01 22:08:41

我使用路径/actuator/health/readiness/actuator/health/liveness

代码语言:javascript
复制
readinessProbe:
  initialDelaySeconds: 120
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 5
  failureThreshold: 3
  httpGet:
    scheme: HTTP
    path: /actuator/health/readiness
    port: 8080

livenessProbe:
  initialDelaySeconds: 120
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 5
  failureThreshold: 3
  httpGet:
    scheme: HTTP
    path: /actuator/health/liveness
    port: 8080

对于建议,它实际上取决于您的需求和策略( https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ )

这方面没有任何问题:)

不要忘记激活属性中的端点(cf https://www.baeldung.com/spring-liveness-readiness-probes):

代码语言:javascript
复制
management.endpoint.health.probes.enabled=true
management.health.livenessState.enabled=true
management.health.readinessState.enabled=true
票数 2
EN

Stack Overflow用户

发布于 2022-11-17 13:50:48

除了@B猜测答案和部分:

对于建议,这取决于您的需要和政策。

我们的一些微服务与笨重/慢的容器通信,这些容器需要时间来启动,因此我们必须使用启动探针来保护它们。https://kubernetes.io/推荐的方法是使用活动端口,与弹簧引导执行器端点的连接会产生以下结果:

代码语言:javascript
复制
readinessProbe:
  httpGet:
    path: /actuator/health/readiness
    port: http
  periodSeconds: 5
livenessProbe:
  httpGet:
    path: /actuator/health/liveness
    port: http
  periodSeconds: 5
startupProbe:
  httpGet:
    path: /actuator/health/liveness
    port: http
  failureThreshold: 25
  periodSeconds: 10

上述设置确保在应用程序完全启动时探测livenessreadiness (有10*25=250秒)。正如医生所说:

如果配置了这样的探测,它将禁用活性检查和准备状态检查,直到成功为止,确保这些探测不会干扰应用程序启动。

请注意,在Kubernetes中运行的应用程序不需要management.endpoint.health.probes.enabled=true (文档)。

只有当应用程序在Kubernetes环境中运行时,才会自动启用这些健康组。您可以使用management.endpoint.health.probes.enabled configuration属性在任何环境中启用它们。

因此,如果您想要检查探针,例如本地的,您就需要它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72467798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档