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.
There is a flag --terminated-pod-gc-threshold
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.
--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 <= 0, the terminated pod garbage collector is disabled.
So your best bet is to write a script and run it in schedule.
https://gist.github.com/psxvoid/71492191b7cb06260036c90ab30cc9a0