<p>Is there a way for a <code>Deployment</code> or <code>Job</code> to completely delete itself upon completion?</p>
<p>I want it such that when I do <code>kubectl get jobs/deployments/pods</code> they don't show up after they finished (container exited).</p>
<p>One possible way I thought of was to call <code>kubectl delete jobs/deployments/pods</code> from within the container but I'm not sure if that's safe.</p>

Mr.UNOwen
<p>I found a related <a href="https://stackoverflow.com/a/43116061/4242336">question and answer</a>, but found out it is for <code>CronJobs</code>.</p>
<p>Following that answer, there is a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/" rel="nofollow noreferrer">TTL Controller</a> introduced <code>Alpha</code> in <code>1.12</code> and <code>Beta</code> in <code>1.21</code>.
You have to manually enable it in <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/" rel="nofollow noreferrer">Feature Gates</a> before <code>v1.21</code>.</p>
<p>According to the docs:</p>
<blockquote>
<p>provides a TTL (time to live) mechanism to limit the lifetime of resource objects that have finished execution. TTL controller only handles Jobs for now, and may be expanded to handle other resources that will finish execution, such as Pods and custom resources.</p>
</blockquote>
<p>It could clean up <code>Jobs</code> currently and others in plan.</p>
