I am trying to analyse whether or not to use "/actuator/health/liveness" and "/actuator/health/readiness" instead of "/actuator/health". I mainly used https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot for information.
I discovered that the http response of "/actuator/health/liveness" and "/actuator/health/readiness" changes when additionaly configuring "management.endpoint.health.group.liveness/readiness.show-details = always".
When "killing" an external dependency (e.g.: rabbitMq) the probe endpoints now respond with 503 while simultaiously repling with "readinessState": {"status": "UP"},
When removing the "management.endpoint.health.group.liveness/readiness.show-details = always" the endpoint now correctly respond with http 200.
Is this intended behaviour? Only dispalying more information changes the behavior of the probe since kubernetes uses the http response code the decide weather or not to "kill" / loadbalance to a pod.
This is due to an unfortunate side effect of setting one of the group's properties.
When you set management.endpoint.health.group.liveness.show-details
(or any other "management.endpoint.health.group.liveness.*
property) you're replacing Spring Boot's default liveness
group with one of your own. By default, a group includes all health indicators which is why the health of RabbitMQ now affects the response.
You can avoid the problem by configuring the group's membership at the same time as configuring it to show details:
management.endpoint.health.group.liveness.show-details=true
management.endpoint.health.group.liveness.include=livenessState
Equivalent configuration for the readiness group is the following:
management.endpoint.health.group.readiness.show-details=true
management.endpoint.health.group.readiness.include=readinessState
This membership matches Spring Boot's defaults where the only member of the liveness
group is livenessState
and the only member of the readiness
group is readinessState
.
https://github.com/spring-projects/spring-boot/issues/40268 is tracking an improvement to Spring Boot that will make this more intuitive and remove the need to configure the group's membership when changing one of its other settings.