<p>I have triggered a cronjob and even after successful completion of the job it is not cleaning the pods.
Here are two statements that may help to understand it better.</p>
<p><code>successfulJobsHistoryLimit: 0</code></p>
<p><code>terminationGracePeriodSeconds: 30</code></p>
<p>Here I have set the successfulJobsHistoryLimit to 0 still it is not cleaning the pods even though they are in the completed state.</p>
<p>But if I use <code>ttlSecondsAfterFinished</code>, then it is cleaning the pods.</p>
<p>So my question is, Even after <code>successfulJobsHistory</code> is set to 0, Why is <code>ttlSecondsAfterFinished</code>required to clean the pods of the job which is successfully completed?</p>

rebel_roar
<p><code>successfulJobsHistoryLimit</code> refers to the entity <code>Job</code> which is a separate entity from <code>Pod</code></p>
<p>while  <code>terminationGracePeriodSeconds</code>, <code>ttlSecondsAfterFinished</code> refer to <code>Pods</code></p>
<p>when set <code>successfulJobsHistoryLimit</code> to 0, if you do <code>kubectl get job</code> you should not see entries for that specific job. but the pods stay as seen by <code>kubectl get pods</code></p>
<p>pods which run to completion stay in the history until deleted or until its Job is deleted manually as it seems. thats why you still need   <code>ttlSecondsAfterFinishedrequired </code> to delete them. this property is managed regardless of <code>Job</code> entity and is specific to Pods.</p>
<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup" rel="nofollow noreferrer">job-termination-and-cleanup</a> states that:</p>
<blockquote>
<p>When a Job completes, no more Pods are created, but the Pods are usually not deleted either. Keeping them around allows you to still view the logs of completed pods to check for errors, warnings, or other diagnostic output. The job object also remains after it is completed so that you can view its status. It is up to the user to delete old jobs after noting their status. Delete the job with kubectl (e.g. kubectl delete jobs/pi or kubectl delete -f ./job.yaml). When you delete the job using kubectl, all the pods it created are deleted too.</p>
</blockquote>
<p>Its implied that pods arent deleted automatically unless the job is manually deleted, but not when its history entries are auto deleted.</p>
