How Kubernetes picks which pods to delete during scale-in

Source: https://rpadovani.com/k8s-algorithm-pick-pod-scale-in

Have you ever wondered how K8s choose which pods to delete when a deployment is scaled down? Given it is not documented, I dived in the source code to learn.

TLTR:

There are 8 different rules: when comparing two pods, each of them is applied in turn until one matches.

If all these 8 criteria are the same, so there is no clear indication of which pod should be deleted first, they are sorted by UUID to provide a pseudorandom order. The one that comes before in alphabetical order will be deleted first.

Tags:
#google #kubernetes #gke