1
votes

Hi openshift community,

I am currently migrating an app to Openshift and has encountered failed health probes due to connection refused. What I find strange is that if I ssh into the pod and use curl localhost:10080/xxx-service/info It returns HTTP 200 but if I use the IP address then it fails with

This is the details:

  1. POD status

enter image description here

  1. Logs in Openshift saying Spring boot started successfully

enter image description here

  1. Openshift events saying probes failed due to connection refused

enter image description here

  1. Tried SSH to pod to check using localhost which works

enter image description here

Not sure why the IP address is not resolving at the POD level.... Does anyone know the answer or have encountered it?

2

2 Answers

0
votes

It is hard to say in your case what exactly the issue is, as it is environment specific.

In general, you should avoid using IP addresses when working with Kubernetes, as these will change whenever a Pod is restarted (which may be the root cause for the issue you are seeing).

When defining readiness and liveness probes for your container, I would recommend that you always use the following syntax to define your checks (note that it does not specify the host):

...
readinessProbe:
  httpGet:
    path: /xxx-service/info
    port: 10080
  initialDelaySeconds: 15
  timeoutSeconds: 1
...

See also the Kubernetes or OpenShift documentation for more information:

0
votes

I found the root cause, it turns out it was Spring related.

It was a Spring Boot app that was being packaged as WAR file and deployed to Tomcat server. In the application.properties, it had this field:

server.address=127.0.0.1

Removing it has fixed this issue.

https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#common-application-properties-server