<p>Since Kubernetes does not implement a dependency between Containers, I was wondering whether there is an elegant way of checking whether another Container in the same Pod is ready.</p>

<p>I would assume the Downward API is necessary.
Maybe it could be done by embedding <code>kubectl</code> inside the container - but is there a easier way?</p>

<p>Waiting container from <em>other pod</em> to be ready is easily done by using init container that will do a check (typically a curl on the health endpoint or anything else) until receiving an acceptable answer. On a container within the same pod, this solution will not work, but you can use the <code>command</code> part of the container specification do achieve a something quite similar.</p>

<p>For an HTTP service :</p>

<pre><code>    command:
    - '/bin/sh'
    - '-c'
    - &gt;
      set -ex;
      until curl --fail --connect-timeout 5 http://localhost:8080/login; do sleep 2; done
      &amp;&amp; &lt;start command&gt;
</code></pre>

<p>You can easily achieve the same for a postgres database :</p>

<pre><code>    command:
    - '/bin/bash'
    - &gt;
      until pg_isready --host localhost -p 5432; do sleep 2; done
      &amp;&amp; bash /sql/00-postgres-configuration.sh
</code></pre>

<p>Those are juste example, you must determine the best way to detect of your other container is up or not.</p>

<p>Have a look at <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/</a> to see how you can specify <code>command</code> to a pod.</p>
