Skip to content

Commit

Permalink
koord-descheduler: balance prod pods between nodes in LowNodeLoad (ko…
Browse files Browse the repository at this point in the history
…ordinator-sh#2066)

Signed-off-by: zwForrest <[email protected]>
  • Loading branch information
zwForrest authored Jun 13, 2024
1 parent e810c07 commit 4bd7021
Show file tree
Hide file tree
Showing 11 changed files with 845 additions and 109 deletions.
21 changes: 17 additions & 4 deletions pkg/descheduler/apis/config/types_loadaware.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type LowNodeLoadArgs struct {

// NumberOfNodes can be configured to activate the strategy only when the number of under utilized nodes are above the configured value.
// This could be helpful in large clusters where a few nodes could go under utilized frequently or for a short period of time.
// This parameter includes the sum of nodes with low node utilization, low prod utilization, and both.
// By default, NumberOfNodes is set to zero.
NumberOfNodes int32

Expand Down Expand Up @@ -65,12 +66,18 @@ type LowNodeLoadArgs struct {
// A resource consumption above (resp. below) this window is considered as overutilization (resp. underutilization).
UseDeviationThresholds bool

// HighThresholds defines the target usage threshold of resources
// HighThresholds defines the target usage threshold of node resources
HighThresholds ResourceThresholds

// LowThresholds defines the low usage threshold of resources
// LowThresholds defines the low usage threshold of node resources
LowThresholds ResourceThresholds

// ProdHighThresholds defines the target usage threshold of Prod resources
ProdHighThresholds ResourceThresholds

// ProdLowThresholds defines the low usage threshold of Prod resources
ProdLowThresholds ResourceThresholds

// ResourceWeights indicates the weights of resources.
// The weights of resources are both 1 by default.
ResourceWeights map[corev1.ResourceName]int64
Expand All @@ -97,12 +104,18 @@ type LowNodeLoadNodePool struct {
// A resource consumption above (resp. below) this window is considered as overutilization (resp. underutilization).
UseDeviationThresholds bool

// HighThresholds defines the target usage threshold of resources
// HighThresholds defines the target usage threshold of node resources
HighThresholds ResourceThresholds

// LowThresholds defines the low usage threshold of resources
// LowThresholds defines the low usage threshold of node resources
LowThresholds ResourceThresholds

// ProdHighThresholds defines the target usage threshold of Prod resources
ProdHighThresholds ResourceThresholds `json:"prodHighThresholds,omitempty"`

// ProdLowThresholds defines the low usage threshold of Prod resources
ProdLowThresholds ResourceThresholds `json:"prodLowThresholds,omitempty"`

// ResourceWeights indicates the weights of resources.
// The weights of resources are both 1 by default.
ResourceWeights map[corev1.ResourceName]int64
Expand Down
2 changes: 2 additions & 0 deletions pkg/descheduler/apis/config/v1alpha2/conversion_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func Convert_v1alpha2_LowNodeLoadArgs_To_config_LowNodeLoadArgs(in *LowNodeLoadA
UseDeviationThresholds: out.UseDeviationThresholds,
HighThresholds: out.HighThresholds,
LowThresholds: out.LowThresholds,
ProdHighThresholds: out.ProdHighThresholds,
ProdLowThresholds: out.ProdLowThresholds,
ResourceWeights: out.ResourceWeights,
AnomalyCondition: out.AnomalyCondition,
}
Expand Down
21 changes: 17 additions & 4 deletions pkg/descheduler/apis/config/v1alpha2/types_loadaware.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type LowNodeLoadArgs struct {

// NumberOfNodes can be configured to activate the strategy only when the number of under utilized nodes are above the configured value.
// This could be helpful in large clusters where a few nodes could go under utilized frequently or for a short period of time.
// This parameter includes the sum of nodes with low node utilization, low prod utilization, and both.
// By default, NumberOfNodes is set to zero.
NumberOfNodes *int32 `json:"numberOfNodes,omitempty"`

Expand Down Expand Up @@ -64,12 +65,18 @@ type LowNodeLoadArgs struct {
// A resource consumption above (resp. below) this window is considered as overutilization (resp. underutilization).
UseDeviationThresholds *bool `json:"useDeviationThresholds,omitempty"`

// HighThresholds defines the target usage threshold of resources
// HighThresholds defines the target usage threshold of node resources
HighThresholds ResourceThresholds `json:"highThresholds,omitempty"`

// LowThresholds defines the low usage threshold of resources
// LowThresholds defines the low usage threshold of node resources
LowThresholds ResourceThresholds `json:"lowThresholds,omitempty"`

// ProdHighThresholds defines the target usage threshold of Prod resources
ProdHighThresholds ResourceThresholds `json:"prodHighThresholds,omitempty"`

// ProdLowThresholds defines the low usage threshold of Prod resources
ProdLowThresholds ResourceThresholds `json:"prodLowThresholds,omitempty"`

// ResourceWeights indicates the weights of resources.
// The weights of CPU and Memory are both 1 by default.
ResourceWeights map[corev1.ResourceName]int64 `json:"resourceWeights,omitempty"`
Expand All @@ -96,12 +103,18 @@ type LowNodeLoadNodePool struct {
// A resource consumption above (resp. below) this window is considered as overutilization (resp. underutilization).
UseDeviationThresholds bool `json:"useDeviationThresholds,omitempty"`

// HighThresholds defines the target usage threshold of resources
// HighThresholds defines the target usage threshold of node resources
HighThresholds ResourceThresholds `json:"highThresholds,omitempty"`

// LowThresholds defines the low usage threshold of resources
// LowThresholds defines the low usage threshold of node resources
LowThresholds ResourceThresholds `json:"lowThresholds,omitempty"`

// ProdHighThresholds defines the target usage threshold of Prod resources
ProdHighThresholds ResourceThresholds `json:"prodHighThresholds,omitempty"`

// ProdLowThresholds defines the low usage threshold of Prod resources
ProdLowThresholds ResourceThresholds `json:"prodLowThresholds,omitempty"`

// ResourceWeights indicates the weights of resources.
// The weights of resources are both 1 by default.
ResourceWeights map[corev1.ResourceName]int64 `json:"resourceWeights,omitempty"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions pkg/descheduler/apis/config/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions pkg/descheduler/apis/config/validation/validation_loadaware.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ func ValidateLowLoadUtilizationArgs(path *field.Path, args *deschedulerconfig.Lo
}
}

for resourceName, percentage := range nodePool.ProdHighThresholds {
if percentage < 0 {
allErrs = append(allErrs, field.Invalid(nodePoolPath.Child("ProdHighThresholds").Key(string(resourceName)), percentage, "percentage must be greater than or equal to 0"))
}
if nodeHighPercentage, ok := nodePool.HighThresholds[resourceName]; ok && percentage > nodeHighPercentage {
allErrs = append(allErrs, field.Invalid(nodePoolPath.Child("ProdHighThresholds").Key(string(resourceName)), percentage, "node percentage must be greater than or equal to prodHighThresholds"))
}
}
for resourceName, percentage := range nodePool.ProdLowThresholds {
if percentage < 0 {
allErrs = append(allErrs, field.Invalid(nodePoolPath.Child("ProdLowThresholds").Key(string(resourceName)), percentage, "percentage must be greater than or equal to 0"))
}
if highProdPercentage, ok := nodePool.ProdHighThresholds[resourceName]; ok && percentage > highProdPercentage {
allErrs = append(allErrs, field.Invalid(nodePoolPath.Child("ProdLowThresholds").Key(string(resourceName)), percentage, "low percentage must be less than or equal to prodHighThresholds"))
}
}

if nodePool.AnomalyCondition.ConsecutiveAbnormalities <= 0 {
fieldPath := nodePoolPath.Child("anomalyDetectionThresholds").Child("consecutiveAbnormalities")
allErrs = append(allErrs, field.Invalid(fieldPath, nodePool.AnomalyCondition.ConsecutiveAbnormalities, "consecutiveAbnormalities must be greater than 0"))
Expand Down
28 changes: 28 additions & 0 deletions pkg/descheduler/apis/config/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4bd7021

Please sign in to comment.