<p>I want to deploy redis pod which loads a list. Then I will have kubernetes job which will execute bash script with variable taken from that list in redis.</p>
<p>How can I make this redis pod to be auto deleted when all items from a list are used?</p>

<p>By default, Kubernetes keeps the completed jobs and associated objects for debugging purposes, and you will lose all the generated logs by them when deleted.</p>
<p>That being said, a job can be automatically deleted by using the <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/#ttl-mechanism-for-finished-jobs" rel="nofollow noreferrer">TTL mechanism for finished Jobs</a>.</p>
<p>Here you can find an example of a job's manifest with the TTL enabled and set to delete the job and associated objects (pods, services, etc.) 100 sec after its completion:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: pi-with-ttl
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: [&quot;perl&quot;,  &quot;-Mbignum=bpi&quot;, &quot;-wle&quot;, &quot;print bpi(2000)&quot;]
      restartPolicy: Never
</code></pre>
