当前位置: 首页 > 知识库问答 >
问题:

Spring引导执行器Kubernetes探针返回404

厍兴腾
2023-03-14
management.endpoints.web.path-mapping.health=probes
management.endpoint.health.group.ping.include=ping
management.endpoint.health.group.liveness.include=livenessState
management.endpoint.health.group.readiness.include=readinessState

按预期列出了这些组:

$ curl http://localhost:8080/actuator/probes
{"status":"UP","groups":["liveness","ping","readiness"]}

ping按预期工作:

$ curl http://localhost:8080/actuator/probes/ping
{"status":"UP"}

但是,活性就绪都返回状态代码:404内容长度:0

我想要的探测记录在自动配置的HealthIndicator列表中。

在https://spring.io/blog/2020/03/25/liveness-and-readid-probes-with-spring-boot中也介绍了该特性。

我尝试了livenessstate的几个拼写,插入了livenessprobe(在博客文章中),但没有效果。

这里有一个相关的答案,但它并不直接解决我的问题:Kubernetes-Liveness and Readision probe实现

我缺少了什么配置?

链接的站点中有一些词语暗示了潜在的线索。

也许这表明探测器只有部署在Kubernetes环境中才起作用--尽管我不知道如何检测到这种情况,也不知道为什么会出现这种情况。

共有1个答案

黄靖
2023-03-14

添加以下配置对我有效(通过反复试验)

management.health.livenessstate.enabled=true
management.health.readinessstate.enabled=true

如果在本地运行,还需要添加

management.endpoint.health.probes.enabled=true

我使用的是spring-boot-starter-parent版本2.3.2.release

 类似资料:
  • HTTP-获取http://:8080/acturet/health delay=60s timeout=20s period=10s#success=1#failure=3 如何知道活跃度探测是否实际与默认执行器的健康endpoint一起运行

  • 在生产中,我想禁用/acturetatorendpoint,但仍然允许/acturetator/health。我使用SecurityConfigurerAdapter尝试了下面的代码,但它返回500。我想返回一个404,并得到一个“页面找不到”错误页面。非常感谢任何帮助

  • 我们的情况是,我们有大量的Spring Boot应用程序运行在容器(在OpenShift上)中,这些容器访问集中的基础设施(在pod外部),如数据库、队列等。 如果一个中央基础设施坏了,健康检查会返回“不健康”(这是正确的)。问题是,活跃度检查看到了这一点,并重新启动了pod(就绪检查然后看到它也下降了,所以不会启动应用程序)。当只有几个应用程序可用时,这是很好的,但如果许多(可能有数百个)应用程

  • 如何为我的spring boot应用程序编写kubernetes Readision probe(启动大约需要20秒)?我试着从配置活跃度、就绪和启动探测中学习,但我不知道Kubernetes是如何将状态代码200计算为成功的

  • 从这份官方文件中,很难确定这两个模块之间有什么区别。 谁能提供一个官方和规范的答案来解释两者的区别吗?

  • {“Status”:“Down”} 我需要做什么才能显示自定义健康状况指示器?