title: How to cleanup failed CronJob spawned Jobs once a more recent job passes
body: <p>I am running management tasks using Kubernetes CronJobs and have Prometheus alerting on when one of the spawned Jobs fails using <a href="https://github.com/kubernetes/kube-state-metrics" rel="nofollow noreferrer">kube-state-metrics</a>:</p>
  
  <pre><code>kube_job_status_failed{job="kube-state-metrics"}  &gt; 0
  </code></pre>
  
  <p>I want to have it so that when a more recent Job passes then the failed ones are cleaned up so that the alert stops firing.</p>
  
  <p>Does the CronJob resource support this behaviour on its own?</p>
  
  <p>Workarounds would be to make the Job clean up failed ones as the last step or to create a much more complicated alert rule to take the most recent Job as the definitive status, but they are not the nicest solutions IMO.</p>
  
  <p>Kubernetes version: <code>v1.15.1</code></p>