【发布时间】:2020-10-28 05:58:25
【问题描述】:
我正在尝试使用 Spring Boot Actuator 中的 Kubernetes Probes,但它不起作用。
我在 application.properties 中设置了以下内容:
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"}
但是liveness 和readiness 都返回Status Code: 404 和Content-Length: 0。
我正在使用spring-boot-starter-parent 版本2.3.1.RELEASE。
我想要的探测记录在Auto-configured HealthIndicators的列表中。
该功能也描述在:https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot。
我尝试了几种livenessState 的拼写,包括livenessProbe(在博文中),但没有任何效果。
这是一个相关的答案,但它并没有直接解决我的问题:Kubernetes - Liveness and Readiness probe implementation
我缺少什么配置?
更新
链接网站中存在一些暗示潜在线索的措辞...
如果部署在 Kubernetes 环境中,执行器将收集“Liveness”和“Readiness”信息...
也许这表明探针只有在部署在 Kubernetes 环境中才能工作——尽管我不知道如何检测到这种情况或为什么会出现这种情况。
【问题讨论】:
-
点击下面评论中的链接,我发现 2.3.2 中引入了一个重大更改:github.com/spring-projects/spring-boot/issues/…