mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #29212 from sjenning/hpa-idling
Automatic merge from submit-queue HPA: ignore scale targets whose replica count is 0 Disable HPA when the user (or another component) explicitly sets the replicas to 0. Fixes #28603 @kubernetes/autoscaling @fgrzadkowski @kubernetes/rh-cluster-infra @smarterclayton @ncdc <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.kubernetes.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.kubernetes.io/reviews/kubernetes/kubernetes/29212) <!-- Reviewable:end -->
This commit is contained in:
commit
b39cde37c9
@ -271,7 +271,10 @@ func (a *HorizontalController) reconcileAutoscaler(hpa *autoscaling.HorizontalPo
|
||||
rescaleReason := ""
|
||||
timestamp := time.Now()
|
||||
|
||||
if currentReplicas > hpa.Spec.MaxReplicas {
|
||||
if scale.Spec.Replicas == 0 {
|
||||
// Autoscaling is disabled for this resource
|
||||
desiredReplicas = 0
|
||||
} else if currentReplicas > hpa.Spec.MaxReplicas {
|
||||
rescaleReason = "Current number of replicas above Spec.MaxReplicas"
|
||||
desiredReplicas = hpa.Spec.MaxReplicas
|
||||
} else if hpa.Spec.MinReplicas != nil && currentReplicas < *hpa.Spec.MinReplicas {
|
||||
@ -323,7 +326,7 @@ func (a *HorizontalController) reconcileAutoscaler(hpa *autoscaling.HorizontalPo
|
||||
desiredReplicas = *hpa.Spec.MinReplicas
|
||||
}
|
||||
|
||||
// TODO: remove when pod idling is done.
|
||||
// never scale down to 0, reserved for disabling autoscaling
|
||||
if desiredReplicas == 0 {
|
||||
desiredReplicas = 1
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ func TestZeroReplicas(t *testing.T) {
|
||||
minReplicas: 3,
|
||||
maxReplicas: 5,
|
||||
initialReplicas: 0,
|
||||
desiredReplicas: 3,
|
||||
desiredReplicas: 0,
|
||||
CPUTarget: 90,
|
||||
reportedLevels: []uint64{},
|
||||
reportedCPURequests: []resource.Quantity{},
|
||||
|
Loading…
Reference in New Issue
Block a user