Skip to content

Commit

Permalink
Merge pull request #26993 from damemi/dev-1.21-random-downscale
Browse files Browse the repository at this point in the history
Add description of replica controller scaledown sort logic
  • Loading branch information
k8s-ci-robot authored Mar 22, 2021
2 parents b7e6963 + 10162f7 commit fddac2d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions content/en/docs/concepts/workloads/controllers/replicaset.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@ assuming that the number of replicas is not also changed).
A ReplicaSet can be easily scaled up or down by simply updating the `.spec.replicas` field. The ReplicaSet controller
ensures that a desired number of Pods with a matching label selector are available and operational.

When scaling down, the ReplicaSet controller chooses which pods to delete by sorting the available pods to
prioritize scaling down pods based on the following general algorithm:
1. Pending (and unschedulable) pods are scaled down first
2. If controller.kubernetes.io/pod-deletion-cost annotation is set, then
the pod with the lower value will come first.
3. Pods on nodes with more replicas come before pods on nodes with fewer replicas.
4. If the pods' creation times differ, the pod that was created more recently
comes before the older pod (the creation times are bucketed on an integer log scale)

If all of the above match, then selection is random.

### ReplicaSet as a Horizontal Pod Autoscaler Target

A ReplicaSet can also be a target for
Expand Down

0 comments on commit fddac2d

Please sign in to comment.