mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Cluster autoscaler friendly scheduling algorithm
This commit is contained in:
parent
2707c46a32
commit
2df92ff155
@ -34,7 +34,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// GCE instances can have up to 16 PD volumes attached.
|
// GCE instances can have up to 16 PD volumes attached.
|
||||||
DefaultMaxGCEPDVolumes = 16
|
DefaultMaxGCEPDVolumes = 16
|
||||||
|
ClusterAutoscalerProvider = "ClusterAutoscalerProvider"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getMaxVols checks the max PD volumes environment variable, otherwise returning a default value
|
// getMaxVols checks the max PD volumes environment variable, otherwise returning a default value
|
||||||
@ -54,6 +55,9 @@ func getMaxVols(defaultVal int) int {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
factory.RegisterAlgorithmProvider(factory.DefaultProvider, defaultPredicates(), defaultPriorities())
|
factory.RegisterAlgorithmProvider(factory.DefaultProvider, defaultPredicates(), defaultPriorities())
|
||||||
|
// Cluster autoscaler friendly scheduling algorithm.
|
||||||
|
factory.RegisterAlgorithmProvider(ClusterAutoscalerProvider, defaultPredicates(),
|
||||||
|
replace(defaultPriorities(), "LeastRequestedPriority", "MostRequestedPriority"))
|
||||||
// EqualPriority is a prioritizer function that gives an equal weight of one to all nodes
|
// EqualPriority is a prioritizer function that gives an equal weight of one to all nodes
|
||||||
// Register the priority function so that its available
|
// Register the priority function so that its available
|
||||||
// but do not include it as part of the default priorities
|
// but do not include it as part of the default priorities
|
||||||
@ -97,6 +101,15 @@ func init() {
|
|||||||
factory.RegisterPriorityFunction("MostRequestedPriority", priorities.MostRequestedPriority, 1)
|
factory.RegisterPriorityFunction("MostRequestedPriority", priorities.MostRequestedPriority, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func replace(set sets.String, replaceWhat, replaceWith string) sets.String {
|
||||||
|
result := sets.NewString(set.List()...)
|
||||||
|
if result.Has(replaceWhat) {
|
||||||
|
result.Delete(replaceWhat)
|
||||||
|
result.Insert(replaceWith)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func defaultPredicates() sets.String {
|
func defaultPredicates() sets.String {
|
||||||
return sets.NewString(
|
return sets.NewString(
|
||||||
// Fit is determined by non-conflicting disk volumes.
|
// Fit is determined by non-conflicting disk volumes.
|
||||||
|
Loading…
Reference in New Issue
Block a user