<p>I have an AKS. Managed cluster and Microsoft is managing the master. Everything is dandy, except that I am seeing a lot of Evicted pods, from time to time I go and delete these "Evicted pods". How / Where should I set a policy to clean up these Evited pods automatically specifically in Azure AKS.</p>

<p>There is a flag <code>--terminated-pod-gc-threshold</code> in Kubernetes controller manager component. But since the cluster is managed by Microsoft you can not modify the flag and set the default value to a lower.</p>

<pre><code>--terminated-pod-gc-threshold int32     Default: 12500
Number of terminated pods that can exist before the terminated pod garbage collector starts deleting terminated pods. If &lt;= 0, the terminated pod garbage collector is disabled.
</code></pre>

<p>So your best bet is to write a script and run it in schedule.</p>

<p><a href="https://gist.github.com/psxvoid/71492191b7cb06260036c90ab30cc9a0" rel="nofollow noreferrer">https://gist.github.com/psxvoid/71492191b7cb06260036c90ab30cc9a0</a></p>
