<p>Goal is to terminate the pod after completion of Job.
This is my yaml file. Currently, my pod status is <strong>completed</strong> after running the job.</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  # Unique key of the Job instance
  name: example-job
spec:
  template:
    metadata:
      name: example-job
    spec:
      containers:
      - name: container-name
        image: my-img
        command: [&quot;python&quot;, &quot;main.py&quot;]
      # Do not restart containers after they exit
      restartPolicy: Never
  # of retries before marking as failed.
  backoffLimit: 4 
</code></pre>

<p>You can configure and remove the jobs once complete</p>
<p>inside the YAML you can configure limit of keeping the PODs</p>
<pre><code>successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 0
</code></pre>
<p>you can set the <strong>history limits</strong> using above config in YAML.</p>
<blockquote>
<p>The .spec.successfulJobsHistoryLimit and .spec.failedJobsHistoryLimit
fields are optional. These fields specify how many completed and
failed jobs should be kept. By default, they are set to 3 and 1
respectively. Setting a limit to 0 corresponds to keeping none of the
corresponding kind of jobs after they finish.</p>
</blockquote>
<p><code>backoffLimit: 4</code> will retires a number of times and try to run the job before marking it as a failed one.</p>
<p>Read more at : <a href="https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#jobs-history-limits" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#jobs-history-limits</a></p>
