I have deployed my service running on spring boot in openshift. The spring boot service initializes good and we see the below logs which is good.
2020-05-06 19:32:33.930 INFO 1 --- [ main] c.a.r.l.MyApplication : Started MyApplication in 44.227 seconds (JVM running for 67.578)
2020-05-06 19:32:38.706 INFO 1 --- [nio-8198-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-06 19:32:38.709 INFO 1 --- [nio-8198-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-06 19:32:38.802 INFO 1 --- [nio-8198-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 93 msHowever the containers ready status shows 0/1 and after 5 mins i see this warning and the pod restarts.
The container has been running for more than five minutes and has not passed its readiness check
and i see
Readiness probe failed: HTTP probe failed with statuscode: 404
What could be wrong?
Readiness probe failed: HTTP probe failed with statuscode: 404This indicates that the URL that you specified for your readinessProbe does not exist (HTTP 404). So check how your readinessProbe is defined (which URI is called) and make sure there is a valid response.
For Spring Boot, there is an actuator available for Health endpoints, see the following documentation: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html
Here is an example:
[..]
spec:
containers:
- args:
image: k8s.gcr.io/readiness
readinessProbe:
httpGet:
path: /healthzIn the example above, make sure that the /healthz endpoint exists.
You can find more information on how to configure Readiness Probes in the OpenShift documentation.