<p>How can I configure my Deployment to do a health check on the sprint boot actuator endpoint?
I'm using spring boot 2 running on port 9000. (PS: port-forward test works)</p>

<p>This is the error:</p>

<pre><code>Readiness probe failed: Get http://10.48.0.116:9000/actuator/health: dial tcp 10.48.0.116:9000: connect: connection refused
</code></pre>

<p>And that is my Deployment yml:</p>

<pre><code>apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: my-api
  namespace: vidolin
  labels:
    stack: api
    app: my-api
spec:
  replicas: 1
  selector:
    matchLabels:
      stack: api
      app: my-api
  template:
    metadata:
      labels:
        stack: api
        app: my-api
    spec:
      imagePullSecrets:  
      - name: itdevregistry
      containers:
      - name: primary
        image: vidolinregistry.azurecr.io/my/api
        ports:
        - containerPort: 9000
        envFrom:
        - configMapRef:
            name: my-api-config
        readinessProbe:
          httpGet:
            path: /actuator/health
            port: 9000
          initialDelaySeconds: 10
          timeoutSeconds: 2
          periodSeconds: 3
          failureThreshold: 1
        livenessProbe:
          httpGet:
            path: /actuator/health
            port: 9000
          initialDelaySeconds: 20
          timeoutSeconds: 2
          periodSeconds: 8
          failureThreshold: 1
</code></pre>

<p>Although I am replying a bit late. But I think my implementation will help people in future to implement kubernetes readiness / liveness probe for spring boot applications.</p>

<p>Description of my docker image</p>

<ol>
<li>Built from alpine linux</li>
<li>Spring boot 2 application, can be accessible only via SSL</li>
<li>Spring boot actuator implemented /actuator/health which returns {"status":"UP"}</li>
</ol>

<p><strong>So I cannot use httpGet option of kubernetes, as it uses http protocol only.</strong></p>

<p>That is why I create a small shell script "check-if-healthy.sh" as part of docker image to know the status</p>

<pre><code>check-if-healthy.sh
===================
curl -k https://localhost:8888/actuator/health | grep '"status":"UP"' &gt; /dev/null &amp;&amp; exit 0 || exit 1
</code></pre>

<p>Please note you need to add this script into docker image, so that it will be available in running container and accessible to kubernetes, As kubernetes will fire <strong>"docker exec /bin/ash /home/config-server/check-if-healthy."</strong> like this</p>

<pre><code>COPY docker/check-if-healthy.sh /home/config-server/check-if-healthy.sh
</code></pre>

<p>And then used "exec" option of kubernetes readiness probe to call the script like this.</p>

<pre><code>      readinessProbe:
        exec:
          command:
            - /bin/ash
            - /home/config-server/check-if-healthy.sh
        initialDelaySeconds: 5
        timeoutSeconds: 1
        failureThreshold: 50
      livenessProbe:
        exec:
          command:
            - /bin/ash
            - /home/config-server/check-if-healthy.sh
        initialDelaySeconds: 5
        timeoutSeconds: 1
        failureThreshold: 50
</code></pre>
