我已经阅读了一些文档,并弄清楚了如何使用 Actuator 设置就绪和活跃端点,例如 this 。但我无法弄清楚如何设置“启动”探针的端点。
我的应用程序yml:
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: "ALWAYS"
group:
readiness.include: readinessProbe, dataStream
startup.include: readinessProbe, dataStream
我的部署配置:
livenessProbe:
httpGet:
path: "/actuator/health/liveness"
port: "http"
initialDelaySeconds: 600
periodSeconds: 15
readinessProbe:
httpGet:
path: "/actuator/health/readiness"
port: "http"
periodSeconds: 30
failureThreshold: 15
startupProbe:
httpGet:
path: "/actuator/health/startup"
port: "http"
initialDelaySeconds: 150
periodSeconds: 10
failureThreshold: 30
执行器似乎没有提供“启动”探针的 URL,或者换句话说,http://localhost:8080/actuator/health/startup 不起作用。我该如何设置?
Spring boot 不会为启动探针公开单独的端点。您也可以将活性探针用于此用例。 在 kubernetes 中使用不同探针的原因是为应用程序的初始启动启用较长的超时,这可能需要一些时间。第一次成功启动探针调用后,活性探针将接管,并减少超时值以快速检测故障并重新启动应用程序。
最简单、最灵活的方法是创建一个新的健康组,其中包括您需要的所有检查。请注意,这些组独立于探针,可在
health/<groupname>
: 获取
management:
endpoint:
health:
group:
startup:
include:
- livenessState
这更加灵活,因为您现在甚至可以包含自定义的额外活性检查,而无需更改启动探针。
确保仅在启用探测器 (
livenessState
) 且默认情况下仅在立方体平台上且包含的检查必须存在的情况下才包含它们。
---
spring.config.activate.on-cloud-platform: kubernetes
management:
endpoint:
health:
group:
startup:
include:
- livenessState
liveness:
include:
- db
- livenessState
作为替代方案,您仍然可以启用探测器(使用
management.endpoint.health.probes.enabled=true
)。
有关更多信息,请查看官方文档。