<p>I'm currently trying to create a job in Kubernetes in a project I've just joined.</p>

<p>This job should wait until 2 other pods are up and running, then run a <strong><em>.sh</em></strong> script to create some data for the testers in the application.</p>

<p>I've figured out i should use <strong><em>initContainers</em></strong>. However, there is one point i don't understand.</p>

<p>Why should i include some environmental values under <strong><em>env</em></strong> tag under <strong><em>initContainers</em></strong> in job description <strong><em>.yaml</em></strong> file ?</p>

<p>I thought i was just waiting for the pods to be initialised, not creating them again. Am i missing something ?</p>

<p>Thanks in advance.</p>

Emre Acar
<p><em>initContainers</em> are like containers running in the Pod, but executed <em>before</em> the ones defined in the spec key <code>containers</code>.</p>

<p>Like <em>containers</em>, they share some namespaces and IPC, so it means that the <a href="https://kubernetes.io/docs/concepts/scheduling/kube-scheduler/" rel="nofollow noreferrer"><em>Scheduler</em></a> will check if the declared <em>initContainers</em> are successful, then it will schedule the containers.</p>

<p>Keep in mind that when you create a Pod, basically, you're creating an empty container named <code>pause</code> that will provide a namespace-base for the following containers: so, in the end, the <em>initContainer</em> is not really creating <em>again</em> a new Pod, like its name suggests, it's an initializer.</p>
