<p>I am on Jenkins 2.73.2.1 and using Kubernetes-jenkins plugin 1.4 to spin up dynamic slaves . However ,I am not able to start up parallel builds. Jenkins always puts it to build queue and executes one at a time.</p>

<p>I have tried setting this while starting jenkins but it doesn't help either:</p>

<pre><code>-Dhudson.slaves.NodeProvisioner.initialDelay=0
-Dhudson.slaves.NodeProvisioner.MARGIN=50
-Dhudson.slaves.NodeProvisioner.MARGIN0=0.85
</code></pre>

<p>Is there any other setting we have to do at plugin configuration end for parallel pods running ?</p>

<p>You have to configure the following parameters correctly in order to run slave concurrently and as per your expectation :</p>

<p>Under <code>Kubernetes Pod Template</code>,</p>

<p>1) Set <code>Labels</code> for Pod template correctly. </p>

<ul>
<li>Make sure you have <code>Jenkins Job</code> with the same label configured.</li>
<li>In that jenkins job's configuration, mark <code>Restrict where this project can be run</code> and provide the same label as you provided in <code>Labels</code> field of Jenkins Configuration.</li>
</ul>

<p>2) Set <code>Max number of instances</code>. This parameter will tell Jenkins <code>How many maximum slaves it can launch with the given label</code> </p>

<p>3) Set <code>Time in minutes to retain agent when idle</code>. This parameter will tell Jenkins <code>Till how much time to retain slave (with the given label) on which no build is running</code>. </p>

<ul>
<li>Correctly configuring this will save you from <code>Kubernetes Pod
Creation time</code>.  </li>
<li>Make sure <code>Pod Retention</code> policy is <code>Default</code>.</li>
</ul>

<p>Under <code>Cloud</code> section,</p>

<p>1) Set <code>Container Cap</code>. This parameter will tell Jenkins <code>How many slaves can be spawned on Kubernetes</code>.</p>

<ul>
<li>This is limit on the total number of Pods that Jenkins can create on <code>Kubernetes cluster</code>.</li>
<li>This limit applies cumulatively to all labels.</li>
<li>Hence, if <code>Max number of instances</code> is greater than <code>Container Cap</code>. Jenkins will only be able to create slaves equal to <code>Container Cap</code> for the label at best.</li>
<li>So ideally keep <code>Container Cap</code> equal to <code>Sum of (Max number of instances) of all labels</code></li>
</ul>

<p>While <code>starting Jenkins</code>,</p>

<ul>
<li>By default, Jenkins spawns agents conservatively. Say, if there are 2
builds in queue, it won't spawn 2 executors immediately. It will
spawn one executor and wait for sometime for the first executor to be
freed before deciding to spawn the second executor. Jenkins makes
sure every executor it spawns is utilized to the maximum. </li>
<li>If you want to override this behaviour and spawn an executor for
each build in queue immediately without waiting, you can use these
flags during Jenkins startup:</li>
</ul>

<blockquote>
<pre><code>-Dhudson.slaves.NodeProvisioner.initialDelay=0
-Dhudson.slaves.NodeProvisioner.MARGIN=50
-Dhudson.slaves.NodeProvisioner.MARGIN0=0.85
</code></pre>
</blockquote>

<p><a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow noreferrer">Jenkins Kuberenetes Plugin' Github</a> repo has good one-line description of all parameters</p>
