<p>I have a job in Kubernetes as defined below (with some omissions for brevity). Parallelism and N completions are set. I want 1 init container to delay the start of the parallel containers. When I run it as-is I get an init container per each completion it appears.</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: my-job
spec:
  parallelism: 10
  completions: 10
  backoffLimit: 0
  template:
    spec:

      # I want 1 of these to run first
      initContainers:
      - name: init-container
        image: my/container:latest
        imagePullPolicy: Always
        command: [&quot;init_script.sh&quot;]

      # I want 10 of these to run in parallel once init_script.sh exits
      containers:
      - name: container
        image: my/container:latest
        imagePullPolicy: Always
        command: [&quot;run_job.sh&quot;]

      restartPolicy: Never
</code></pre>

David Parks
<p>Kubernetes Jobs are very basic and don't provide any advanced scheduling mechanism with scheduling dependencies. For example, the ability to start a job after another job has finished. My advice is to use a more advanced scheduling tool on top of Kubernetes. There are few in open source that you can use. For example.</p>
<ul>
<li><a href="https://volcano.sh/" rel="nofollow noreferrer">Volcano</a> - For example you can use the <a href="https://volcano.sh/docs/jobs/#error-handling" rel="nofollow noreferrer"><code>TaskCompleted</code></a> event.</li>
<li><a href="https://airflow.apache.org/" rel="nofollow noreferrer">Airflow</a> - You can schedule pods directly from the tools and build your <a href="https://kubernetes.io/blog/2018/06/28/airflow-on-kubernetes-part-1-a-different-kind-of-operator/" rel="nofollow noreferrer">DAG (Directed Acyclic Graph).</a></li>
<li>Etc.</li>
</ul>
<p>Two other alternatives:</p>
<ul>
<li>You can even create your own <a href="https://kubernetes.io/docs/tasks/extend-kubernetes/configure-multiple-schedulers" rel="nofollow noreferrer">custom scheduler</a>.</li>
<li>You can build your own <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/operator/" rel="nofollow noreferrer">operator</a> that kicks off your regular jobs based on status.</li>
</ul>
<p>✌️</p>
