<p>I have an application deployed to Kubernetes that depends on an outside application. Sometimes the connection between these 2 goes to an invalid state, and that can only be fixed by restarting my application.</p>
<p>To do automatic restarts, I have configured a liveness probe that will verify the connection.</p>
<p>This has been working great, however, I'm afraid that if that outside application goes down (such that the connection error isn't just due to an invalid pod state), all of my pods will immediately restart, and my application will become completely unavailable. I want it to remain running so that functionality not depending on the bad service can continue.</p>
<p>I'm wondering if a pod disruption budget would prevent this scenario, as it limits the # of pods down due to a &quot;voluntary&quot; disruption. However, the K8s docs don't state whether liveness probe failure are a voluntary disruption. Are they?</p>

roim
<p>Testing with PodDisruptionBudget.
Pod will still restart at the same time.</p>
<h1>example</h1>
<p><a href="https://github.com/AlphaWong/PodDisruptionBudgetAndPodProbe" rel="nofollow noreferrer">https://github.com/AlphaWong/PodDisruptionBudgetAndPodProbe</a></p>
<p>So yes. like @Dawid Kruk u should create a customized script like following</p>
<pre><code># something like this
livenessProbe:
  exec:
    command:
    - /bin/sh
    - -c
    # generate a random number for sleep
    - 'SLEEP_TIME=$(shuf -i 2-40 -n 1);sleep $SLEEP_TIME; curl -L --max-time 5 -f nginx2.default.svc.cluster.local'
  initialDelaySeconds: 10
  # think about the gap between each call
  periodSeconds: 30
  # it is required after k8s v1.12
  timeoutSeconds: 90
</code></pre>
