<p>I have an application that runs a code and at the end it sends an email with a report of the data. When I deploy pods on <strong>GKE</strong> , certain pods get terminated and a new pod is created due to Auto Scale, but the problem is that the termination is done after my code is finished and the email is sent twice for the same data.</p>
<p>Here is the <strong>JSON</strong> file of the deploy API:</p>
<pre><code>{
  &quot;apiVersion&quot;: &quot;batch/v1&quot;,
  &quot;kind&quot;: &quot;Job&quot;,
  &quot;metadata&quot;: {
    &quot;name&quot;: &quot;$name&quot;,
    &quot;namespace&quot;: &quot;$namespace&quot;
  },
  &quot;spec&quot;: {
    &quot;template&quot;: {
      &quot;metadata&quot;: {
        &quot;name&quot;: &quot;********&quot;
      },
      &quot;spec&quot;: {
        &quot;priorityClassName&quot;: &quot;high-priority&quot;,
        &quot;containers&quot;: [
          {
            &quot;name&quot;: &quot;******&quot;,
            &quot;image&quot;: &quot;$dockerScancatalogueImageRepo&quot;,
            &quot;imagePullPolicy&quot;: &quot;IfNotPresent&quot;,
            &quot;env&quot;: $env,
            &quot;resources&quot;: {
              &quot;requests&quot;: {
                &quot;memory&quot;: &quot;2000Mi&quot;,
                &quot;cpu&quot;: &quot;2000m&quot;
              },
              &quot;limits&quot;:{
                  &quot;memory&quot;:&quot;2650Mi&quot;,
                  &quot;cpu&quot;:&quot;2650m&quot;
              }            
             }
          }
        ],
        &quot;imagePullSecrets&quot;: [
          {
            &quot;name&quot;: &quot;docker-secret&quot;
          }
        ],
        &quot;restartPolicy&quot;: &quot;Never&quot;
      }
    }
  }
}
</code></pre>
<p>and here is a screen-shot of the pod events:</p>
<p><a href="https://i.stack.imgur.com/IvZIZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IvZIZ.png" alt="enter image description here" /></a></p>
<p>Any idea how to fix that?</p>
<p>Thank you in advance.</p>

Elias
<p>&quot;Perhaps you are affected by this &quot;Note that even if you specify .spec.parallelism = 1 and .spec.completions = 1 and .spec.template.spec.restartPolicy = &quot;Never&quot;, the same program may sometimes be started twice.&quot; from doc. What happens if you increase terminationgraceperiodseconds in your yaml file? – &quot;</p>
<p>@danyL</p>
