mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-27 02:16:27 +00:00
Add score plugin for NodeResourcesFit
This commit is contained in:
committed by
Abdullah Gharaibeh
parent
06dfe683ce
commit
deb14b995a
@@ -19,6 +19,7 @@ package noderesources
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework"
|
||||
schedutil "k8s.io/kubernetes/pkg/scheduler/util"
|
||||
)
|
||||
@@ -26,6 +27,9 @@ import (
|
||||
// resourceToWeightMap contains resource name and weight.
|
||||
type resourceToWeightMap map[v1.ResourceName]int64
|
||||
|
||||
// scorer is decorator for resourceAllocationScorer
|
||||
type scorer func(args *config.NodeResourcesFitArgs) *resourceAllocationScorer
|
||||
|
||||
// defaultRequestedRatioResources is used to set default requestToWeight map for CPU and memory
|
||||
var defaultRequestedRatioResources = resourceToWeightMap{v1.ResourceMemory: 1, v1.ResourceCPU: 1}
|
||||
|
||||
@@ -124,3 +128,12 @@ func calculatePodResourceRequest(pod *v1.Pod, resource v1.ResourceName, enablePo
|
||||
|
||||
return podRequest
|
||||
}
|
||||
|
||||
// resourcesToWeightMap make weightmap from resources spec
|
||||
func resourcesToWeightMap(resources []config.ResourceSpec) resourceToWeightMap {
|
||||
resourceToWeightMap := make(resourceToWeightMap)
|
||||
for _, resource := range resources {
|
||||
resourceToWeightMap[v1.ResourceName(resource.Name)] = resource.Weight
|
||||
}
|
||||
return resourceToWeightMap
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user