I'm trying to use Kubernetes Probes from Spring Boot Actuator, but it isn't working.
I have set the following in 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
The groups are listed as expected:
$ curl http://localhost:8080/actuator/probes
{"status":"UP","groups":["liveness","ping","readiness"]}
And ping
works as expected:
$ curl http://localhost:8080/actuator/probes/ping
{"status":"UP"}
However both liveness
and readiness
return Status Code: 404
and Content-Length: 0
.
I'm using spring-boot-starter-parent
version 2.3.1.RELEASE
.
The probes I want are documented in the list of Auto-configured HealthIndicators.
The feature is also described at: https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot.
I've tried several spellings of livenessState
, inluding livenessProbe
(which is in the blog post), with no effect.
Here's a related answer, but it doesn't directly address my problem: Kubernetes - Liveness and Readiness probe implementation
What bit of configuration am I missing?
There is some verbiage in the linked sites that indicates a potential clue...
If deployed in a Kubernetes environment, actuator will gather the "Liveness" and "Readiness" information...
Maybe this indicates that the probes only work if deployed in a Kubernetes environment -- although I don't know how that would be detected or why that would be the case.
Increase the Failure Threshold of the Readiness Probe To increase the readiness probe failure threshold, configure the Managed controller item and update the value of "Readiness Failure Threshold". By default, it is set to 100 (100 times). You may increase it to, for example, 300 .
Updating deployments without readiness probes can result in downtime as old pods are replaced by new pods. If the new pods are misconfigured or somehow broken, that downtime extends until you detect the problem and rollback. With readiness probes, Kubernetes will not send traffic to a pod until the probe is successful.
When we deploy our application to Kubernetes, Spring Boot will automatically register these health indicators. As a result, we can use /actuator/health/liveness and /actuator/health/readiness endpoints as our liveness and readiness probes, respectively.
For example, liveness probes could catch a deadlock, where an application is running, but unable to make progress. Restarting a container in such a state can help to make the application more available despite bugs. The kubelet uses readiness probes to know when a container is ready to start accepting traffic.
Adding following configurations worked for me (by trial and error)
management.health.livenessstate.enabled=true
management.health.readinessstate.enabled=true
If you are running locally, you will also need to add
management.endpoint.health.probes.enabled=true
I am using spring-boot-starter-parent
version 2.3.2.RELEASE
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With