<p>I have a program which has multiple independent<sup>1</sup> components. </p>

<p>It is trivial to add a liveness probe in all of the components, however it's not easy to have a <em>single</em> liveness probe which would determine the health of all of the program's components. </p>

<p>How can I make kubernetes look at multiple liveness probes and restart the container when any of those are defunct?</p>

<p>I know it can be achieved by adding more software, for example an additional bash script which does the liveness checks, but I am looking for a native way to do this.</p>

<hr/>

<p><sup>1</sup>By independent I mean that failure of one component does not make the other components fail.</p>

<p>The Kubernetes API allows one liveness and one readness per application (Deployment / POD). I recommend creating a validations centralizing service that has an endpoint rest:</p>

<pre><code>livenessProbe:
  httpGet:
    path: /monitoring/alive
    port: 3401
    httpHeaders:
    - name: X-Custom-Header
      value: Awesome
  initialDelaySeconds: 15
  timeoutSeconds: 1
  periodSeconds: 15

</code></pre>

<p>or try one bash to same task, like:</p>

<pre><code>livenessProbe:
  exec:
    command:
      - bin/bash
      - -c
      - ./liveness.sh
  initialDelaySeconds: 220
  timeoutSeconds: 5

</code></pre>

<p>liveness.sh</p>

<pre><code>#!/bin/sh
if [ $(ps -ef | grep java | wc -l) -ge 1 ]; then
  echo 0
else
  echo "Nothing happens!" 1&gt;&amp;2
    exit 1
fi
</code></pre>

<p>Recalling what the handling of messages can see in the events the failure in question:
"Warning Unhealthy Pod Liveness probe failed: Nothing happens!"</p>

<p>Hope this helps</p>
