nob*_*bar 11 spring-boot-actuator
我正在尝试使用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
Run Code Online (Sandbox Code Playgroud)
这些组按预期列出:
$ curl http://localhost:8080/actuator/probes
{"status":"UP","groups":["liveness","ping","readiness"]}
Run Code Online (Sandbox Code Playgroud)
而ping按预期工作:
$ curl http://localhost:8080/actuator/probes/ping
{"status":"UP"}
Run Code Online (Sandbox Code Playgroud)
但是两者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 环境中,actuator 会收集“Liveness”和“Readiness”信息......
也许这表明探测器仅在部署在 Kubernetes 环境中时才有效——尽管我不知道如何检测到这种情况或为什么会出现这种情况。
Ash*_*jan 14
添加以下配置对我有用(通过反复试验)
management.health.livenessstate.enabled=true
management.health.readinessstate.enabled=true
Run Code Online (Sandbox Code Playgroud)
如果您在本地运行,则还需要添加
management.endpoint.health.probes.enabled=true
Run Code Online (Sandbox Code Playgroud)
我正在使用spring-boot-starter-parent版本2.3.2.RELEASE。
使用include=livenessState或是正确的include=readinessState。这里的例子(显示include=livenessProbe)是错误的。
我通过反复试验确定了正确的名称——在Kubernetes 环境中运行时检查结果。
management.endpoint.health.group.exploratory.include=livenessState,readinessState,ping
management.endpoint.health.group.exploratory.show-details=always
Run Code Online (Sandbox Code Playgroud)
通过某种魔法,并且没有明显的原因,当您进行标准本地运行时,这些指标不可用 - 并且您获得404的健康组没有可用的内容。
以供参考:
| 归档时间: |
|
| 查看次数: |
5141 次 |
| 最近记录: |