<p>I'm trying to create Kubernetes job with the following requirements:</p>
<ol>
<li>Only one pod can be created for each job at most</li>
<li>If the pod failed - the job will fail</li>
<li>Max run time of the pod will be 1 hour</li>
<li>If the job finished successfully - delete the job</li>
</ol>
<p>I tried the following configurations:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Release.Name }}
  annotations:
    &quot;helm.sh/hook&quot;: post-install
    &quot;helm.sh/hook-delete-policy&quot;: hook-succeeded
spec:
  template:
    spec:
      containers:
        - name: {{ .Release.Name }}
          image: {{ .Values.image }}
          env:
            - name: ARG1
              value: {{ required &quot;ARG1 is mandatory&quot; .Values.ENV.ARG1 }}
            - name: GITLAB_USER_EMAIL
              value: {{ .Values.ENV.GITLAB_USER_EMAIL }}
          envFrom:
            - secretRef:
                name: {{ .Release.Name }}
      restartPolicy: Never
  backoffLimit: 1
  activeDeadlineSeconds: 3600
</code></pre>
<p>But it's not working as expected, any ideas?
Thanks !</p>

Zvi Mints
<ul>
<li>Only one pod can be created for each job at most</li>
</ul>
<p>The requested parallelism (.spec.parallelism) can be set to any non-negative value. If it is unspecified, it defaults to 1. If it is specified as 0, then the Job is effectively paused until it is increased.</p>
<blockquote>
<p>For Cronjobs could be helpful <code>successfulJobsHistoryLimit: 0, failedJobsHistoryLimit: 0</code>  this will
remove the PODs if it's get <strong>failed</strong> or <strong>success</strong> so no history or
POD will stays. So only one pod will get created or run.</p>
</blockquote>
<ul>
<li>If the pod failed - the job will fail</li>
</ul>
<p>That will be the default behavior, also <code>restartPolicy: Never</code> so it won't get restarted.</p>
<ul>
<li><p>Max run time of the pod will be 1 hour</p>
<p><code>activeDeadlineSeconds: 3600</code> you have already added</p>
</li>
<li><p>If the job finished successfully - delete the job</p>
</li>
</ul>
<p><code>ttlSecondsAfterFinished: 100</code> will solve your issue.</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Release.Name }}
  annotations:
    &quot;helm.sh/hook&quot;: post-install
    &quot;helm.sh/hook-delete-policy&quot;: hook-succeeded
spec:
  template:
    spec:
      containers:
        - name: {{ .Release.Name }}
          image: {{ .Values.image }}
          env:
            - name: ARG1
              value: {{ required &quot;ARG1 is mandatory&quot; .Values.ENV.ARG1 }}
            - name: GITLAB_USER_EMAIL
              value: {{ .Values.ENV.GITLAB_USER_EMAIL }}
          envFrom:
            - secretRef:
                name: {{ .Release.Name }}
      restartPolicy: Never
  backoffLimit: 1
  ttlSecondsAfterFinished: 100
  activeDeadlineSeconds: 3600
</code></pre>
