mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
EvenPodsSpread: Define a new Priority
This commit is contained in:
parent
9bae1bc568
commit
eefc18a763
17
pkg/scheduler/algorithm/priorities/even_pods_spread.go
Normal file
17
pkg/scheduler/algorithm/priorities/even_pods_spread.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package priorities
|
@ -51,4 +51,7 @@ const (
|
||||
ImageLocalityPriority = "ImageLocalityPriority"
|
||||
// ResourceLimitsPriority defines the nodes of prioritizer function ResourceLimitsPriority.
|
||||
ResourceLimitsPriority = "ResourceLimitsPriority"
|
||||
// EvenPodsSpreadPriority defines the name of prioritizer function that prioritizes nodes
|
||||
// which have pods and labels matching the incoming pod's topologySpreadConstraints.
|
||||
EvenPodsSpreadPriority = "EvenPodsSpreadPriority"
|
||||
)
|
||||
|
@ -87,10 +87,15 @@ func ApplyFeatureGates() {
|
||||
klog.Infof("TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory")
|
||||
}
|
||||
|
||||
// Only register EvenPodsSpreadPredicate if the feature is enabled
|
||||
// Only register EvenPodsSpread predicate & priority if the feature is enabled
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.EvenPodsSpread) {
|
||||
klog.Infof("Registering EvenPodsSpread predicate and priority function")
|
||||
// register predicate
|
||||
factory.InsertPredicateKeyToAlgorithmProviderMap(predicates.EvenPodsSpreadPred)
|
||||
factory.RegisterFitPredicate(predicates.EvenPodsSpreadPred, predicates.EvenPodsSpreadPredicate)
|
||||
// register priority
|
||||
factory.InsertPriorityKeyToAlgorithmProviderMap(priorities.EvenPodsSpreadPriority)
|
||||
factory.RegisterPriorityFunction(priorities.EvenPodsSpreadPriority, priorities.CalculateEvenPodsSpreadPriority, 1)
|
||||
}
|
||||
|
||||
// Prioritizes nodes that satisfy pod's resource limits
|
||||
|
Loading…
Reference in New Issue
Block a user