<p>I've got a spring-boot application deployed in kubernetes, with actuator on port <code>8081</code>. The main application is working on port <code>8080</code>. When I describe the instance, the checks are failing:</p>
<pre><code>$ kubectl describe pod app-844d96f469-8vkbn
...
  Warning  Unhealthy  29s (x4 over 48s)  kubelet            Readiness probe failed: Get &quot;http://192.168.13.189:8081/actuator/health/readiness&quot;: dial tcp 192.168.13.189:8081: connect: connection refused
  Warning  Unhealthy  29s (x2 over 39s)  kubelet            Liveness probe failed: Get &quot;http://192.168.13.189:8081/actuator/health/liveness&quot;: dial tcp 192.168.13.189:8081: connect: connection refused
</code></pre>
<p>When I ssh into the pod, the checks show that the application is healthy, both on localhost and the ip addresses from the error message:</p>
<pre><code>$ kubectl exec -it pod/app-844d96f469-8vkbn -- /bin/sh
# curl localhost:8081/actuator/health/liveness
{&quot;status&quot;:&quot;UP&quot;}
# curl localhost:8081/actuator/health/readiness
{&quot;status&quot;:&quot;UP&quot;}
# curl 192.168.13.189:8081/actuator/health/liveness
{&quot;status&quot;:&quot;UP&quot;}
# curl 192.168.13.189:8081/actuator/health/readiness
{&quot;status&quot;:&quot;UP&quot;}
</code></pre>
<p>The application was healthy within the 10*10=100 second window, so this isn't just an issue of adjusting the threshold and period.</p>
<p>This is the kubernetes config for the checks from the deployment:</p>
<pre><code>        livenessProbe:
          httpGet:
            path: &quot;/actuator/health/liveness&quot;
            port: 8081
          failureThreshold: 10
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: &quot;/actuator/health/readiness&quot;
            port: 8081
          failureThreshold: 10
          periodSeconds: 10
</code></pre>
<p>I'd appreciate any help with this issue!</p>
<hr />
<p><strong>Edit:</strong> Adding the Dockerfile, since Thomas asked if 8081 was exposed on the image. I didn't have to do anything for port 8080 to be exposed, but maybe the question wasn't related to the Dockerfile.</p>
<pre><code>FROM eclipse-temurin:17.0.5_8-jre
RUN mkdir /opt/app
ARG JAR_FILE
COPY ${JAR_FILE} /opt/app/app.jar
ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/opt/app/app.jar&quot;]
</code></pre>

Kevin
<p>I suppose that your application takes too long to become ready before it fails due to liveness probe.
Spring boot / Java applications do heavy initialization on startup and when CPU is limited, it is slow and takes a long time.</p>
<p>Here is a good explanation:
<a href="https://faun.pub/java-application-optimization-on-kubernetes-on-the-example-of-a-spring-boot-microservice-cf3737a2219c" rel="nofollow noreferrer">https://faun.pub/java-application-optimization-on-kubernetes-on-the-example-of-a-spring-boot-microservice-cf3737a2219c</a></p>
<p>A simple service takes 80 seconds on 0.5 CPU while it only takes 12 seconds on 3 CPUs.</p>
<p>If you hava CPU limit set, just leave it out. Only set a request.
And maybe also configure an <code>initialDelaySeconds: 60</code> or so for the liveness probe.</p>
