Merge pull request #5362 from yasinlachiny/maxnodetotal
set cluster_autoscaler_max_nodes_count dynamically
This commit is contained in:
commit
a46a095fe2
|
@ -53,6 +53,7 @@ import (
|
|||
scheduler_utils "k8s.io/autoscaler/cluster-autoscaler/utils/scheduler"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/utils/taints"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/utils/tpu"
|
||||
"k8s.io/utils/integer"
|
||||
|
||||
klog "k8s.io/klog/v2"
|
||||
)
|
||||
|
@ -313,12 +314,18 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError
|
|||
return errors.ToAutoscalerError(errors.CloudProviderError, err)
|
||||
}
|
||||
|
||||
// Update node groups min/max after cloud provider refresh
|
||||
// Update node groups min/max and maximum number of nodes being set for all node groups after cloud provider refresh
|
||||
maxNodesCount := 0
|
||||
for _, nodeGroup := range a.AutoscalingContext.CloudProvider.NodeGroups() {
|
||||
metrics.UpdateNodeGroupMin(nodeGroup.Id(), nodeGroup.MinSize())
|
||||
metrics.UpdateNodeGroupMax(nodeGroup.Id(), nodeGroup.MaxSize())
|
||||
maxNodesCount += nodeGroup.MaxSize()
|
||||
}
|
||||
if a.MaxNodesTotal > 0 {
|
||||
metrics.UpdateMaxNodesCount(integer.IntMin(a.MaxNodesTotal, maxNodesCount))
|
||||
} else {
|
||||
metrics.UpdateMaxNodesCount(maxNodesCount)
|
||||
}
|
||||
|
||||
nonExpendableScheduledPods := core_utils.FilterOutExpendablePods(originalScheduledPods, a.ExpendablePodsPriorityCutoff)
|
||||
// Initialize cluster state to ClusterSnapshot
|
||||
if typedErr := a.initializeClusterSnapshot(allNodes, nonExpendableScheduledPods); typedErr != nil {
|
||||
|
|
|
@ -404,7 +404,6 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
|
|||
|
||||
// These metrics should be published only once.
|
||||
metrics.UpdateNapEnabled(autoscalingOptions.NodeAutoprovisioningEnabled)
|
||||
metrics.UpdateMaxNodesCount(autoscalingOptions.MaxNodesTotal)
|
||||
metrics.UpdateCPULimitsCores(autoscalingOptions.MinCoresTotal, autoscalingOptions.MaxCoresTotal)
|
||||
metrics.UpdateMemoryLimitsBytes(autoscalingOptions.MinMemoryTotal, autoscalingOptions.MaxMemoryTotal)
|
||||
|
||||
|
|
Loading…
Reference in New Issue