Brent Bradburn
Brent Bradburn

Reputation: 54989

Spring Boot Actuator Kubernetes Probes returning 404

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?


Update

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.

Upvotes: 18

Views: 20855

Answers (2)

Ashish Ranjan
Ashish Ranjan

Reputation: 575

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.

Upvotes: 31

Brent Bradburn
Brent Bradburn

Reputation: 54989

It is correct to use include=livenessState or include=readinessState. The example here (which shows include=livenessProbe) is wrong.

I identified the correct name by trial-and-error -- checking the result while running in a Kubernetes environment.

management.endpoint.health.group.exploratory.include=livenessState,readinessState,ping
management.endpoint.health.group.exploratory.show-details=always

By some magic, and for no obvious reason, these indicators aren't available when you do a standard local run -- and you get 404 for health groups that have no available includes.

For reference:

Upvotes: 6

Related Questions