<p>I have two applications - <strong>app1</strong> and <strong>app2</strong>, where <strong>app1</strong> is a <code>config server</code> that holds configs for <strong>app2</strong>. I have defined <code>/readiness</code> endpoint in <strong>app1</strong> and need to wait till it returns <code>OK</code> status to start up pods of <strong>app2</strong>. </p>

<p>It's crucial that deployment of <strong>app2</strong> wait till <code>kubernetes</code> receives <code>Http Status OK</code> from <strong>/readiness</strong> endpoint in <strong>app1</strong> as it's a configuration server and holds crucial configs for app2.</p>

<p>Is it possible to do this kind of deployment dependency?</p>

doublemc
<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#init-containers-in-use" rel="noreferrer"><code>initContainers</code></a>. Following is an example of how you can do in your <code>YAML</code> file</p>
<pre><code>initContainers:
- name: wait-for-other-pod
  image: docker.some.image
  args:
  - /bin/sh
  - -c
  - &gt;
    set -x;
    while [ $(curl -sw '%{http_code}' &quot;http://www.&lt;your_pod_health_check_end_point&gt;.com&quot; -o /dev/null) -ne 200 ]; do
      sleep 15;
    done
</code></pre>
<p>I have used <code>curl</code> to hit the health check endpoint, you can use any other UNIX command to check if the other pod is ready.</p>
<p>If you have a dependency on k8s resources, you can make use of <a href="https://github.com/stackanetes/kubernetes-entrypoint" rel="noreferrer">stackanetes/kubernetes-entrypoint</a> example:</p>
<pre><code>initContainers:
- command:
  - kubernetes-entrypoint
  name: init-dependency-check
  env:
  - name: POD_NAME
    valueFrom:
      fieldRef:
        apiVersion: v1
        fieldPath: metadata.name
  - name: NAMESPACE
    valueFrom:
      fieldRef:
        apiVersion: v1
        fieldPath: metadata.namespace
  - name: DEPENDENCY_SERVICE
  - name: DEPENDENCY_DAEMONSET
  - name: DEPENDENCY_CONTAINER
  - name: DEPENDENCY_POD_JSON
    value: '[{&quot;labels&quot;:{&quot;app.kubernetes.io/name&quot;:&quot;postgres&quot;}}]'
  - name: COMMAND
    value: echo done
  image: projects.registry.vmware.com/tcx/snapshot/stackanetes/kubernetes-entrypoint:latest
  securityContext:
    privileged: true
    runAsUser: 0

</code></pre>
<p>In the above example, the pod with initContainer <code>init-dependency-check</code> will wait until pod with label <code>&quot;app.kubernetes.io/name&quot;:&quot;postgres&quot;</code> is in the Running state. Likewise you can make use of <code>DEPENDENCY_SERVICE</code>, <code>DEPENDENCY_DAEMONSET</code>, <code>DEPENDENCY_CONTAINER</code></p>
