-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add description of replica controller scaledown sort logic #26993
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also list There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add that in #26739 @alculquicondor we should do that for the indexed job annotation too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #27106 |
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that this is too detailed to be useful to users. Also we should avoid locking the criteria in a way that users start relying on it, making it harder to change in the future. In particular, we should state that these are preferences and not something that is guaranteed.
Important downscale selection criteria IMO:
And if they all match, selection is random (the UIDs is 100% an implementation detail that shouldn't go in the documentation).