<p>We have several pods (as service/deployments) in our k8s workflow that are dependent on each other, such that if one goes into a <code>CrashLoopBackOff</code> state, then all these services need to be redeployed. </p>

<p>Instead of having to manually do this, is there a programatic way of handling this?</p>

<p>Of course we are trying to figure out why the pod in question is crashing.</p>

horcle_buzz
<p>First thing to do is making sure that pods are started in correct sequence. This can be done using initContainers like that:</p>

<pre><code>spec:
  initContainers:
  - name: waitfor
    image: jwilder/dockerize
    args:
    - -wait
    - "http://config-srv/actuator/health"
    - -wait
    - "http://registry-srv/actuator/health"
    - -wait
    - "http://rabbitmq:15672"
    - -timeout
    - 600s
</code></pre>

<p>Here your pod will not start until all the services in a list are responding to HTTP probes.</p>

<p>Next thing you may want to define liveness probe that periodically executes curl to the same services</p>

<pre><code>  spec:
    livenessProbe:
      exec:
        command:
        - /bin/sh
        - -c
        - curl http://config-srv/actuator/health &amp;&amp;
          curl http://registry-srv/actuator/health &amp;&amp;
          curl http://rabbitmq:15672
</code></pre>

<p>Now if any of those services fail - you pod will fail liveness probe, be restarted and wait for services to become back online.</p>

<p>That's just an example how it can be done. In your case checks can be different of course.</p>
