Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 338
Brent Bradburn Avatar asked Jul 07 '20 21:07

Brent Bradburn


People also ask

How do I fix the readiness probe failed Kubernetes?

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 .

What happens if readiness probe fails Kubernetes?

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.

How do I enable liveness and readiness in spring boot?

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.

What is the difference between liveness and readiness probe?

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.


1 Answers

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.

like image 78
Ashish Ranjan Avatar answered Sep 20 '22 19:09

Ashish Ranjan