gpt4 book ai didi

spring-boot-actuator - Spring Boot Actuator Kubernetes 探针返回 404

转载 作者:行者123 更新时间:2023-12-03 15:37:32 42 4
gpt4 key购买 nike

我正在尝试使用 Kubernetes Probes来自 Spring Boot Actuator,但它不起作用。
我在 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"}
然而两者都是livenessreadiness返回 Status Code: 404Content-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
我缺少什么配置?

更新
链接网站中有一些文字表明潜在的线索......

If deployed in a Kubernetes environment, actuator will gather the "Liveness" and "Readiness" information...


也许这表明探测器仅在部署在 Kubernetes 环境中时才有效——尽管我不知道如何检测到这种情况或为什么会出现这种情况。

最佳答案

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

management.health.livenessstate.enabled=true
management.health.readinessstate.enabled=true
如果您在本地运行,则还需要添加
management.endpoint.health.probes.enabled=true
我正在使用 spring-boot-starter-parent版本 2.3.2.RELEASE .

关于spring-boot-actuator - Spring Boot Actuator Kubernetes 探针返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62784372/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com