Configurable weight on the CPU and memory

This change also make it possible to score the resources beyond the "cpu"
and "memory" which is currently listed in "defaultRequestedRatioResources".

Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
Dave Chen
2020-04-28 15:47:03 +08:00
parent c096a37226
commit 621c73b984
15 changed files with 581 additions and 28 deletions

View File

@@ -66,6 +66,18 @@ profiles:
- name: ServiceAffinity
args:
affinityLabels: ["bar"]
- name: NodeResourcesLeastAllocated
args:
resources:
- name: cpu
weight: 2
- name: unknown
weight: 1
- name: NodeResourcesMostAllocated
args:
resources:
- name: memory
weight: 1
`),
wantProfiles: []config.KubeSchedulerProfile{
{
@@ -103,6 +115,18 @@ profiles:
AffinityLabels: []string{"bar"},
},
},
{
Name: "NodeResourcesLeastAllocated",
Args: &config.NodeResourcesLeastAllocatedArgs{
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 2}, {Name: "unknown", Weight: 1}},
},
},
{
Name: "NodeResourcesMostAllocated",
Args: &config.NodeResourcesMostAllocatedArgs{
Resources: []config.ResourceSpec{{Name: "memory", Weight: 1}},
},
},
},
},
},
@@ -226,6 +250,10 @@ profiles:
- name: NodeResourcesFit
- name: OutOfTreePlugin
args:
- name: NodeResourcesLeastAllocated
args:
- name: NodeResourcesMostAllocated
args:
`),
wantProfiles: []config.KubeSchedulerProfile{
{
@@ -242,6 +270,18 @@ profiles:
Args: &config.NodeResourcesFitArgs{},
},
{Name: "OutOfTreePlugin"},
{
Name: "NodeResourcesLeastAllocated",
Args: &config.NodeResourcesLeastAllocatedArgs{
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
},
},
{
Name: "NodeResourcesMostAllocated",
Args: &config.NodeResourcesMostAllocatedArgs{
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
},
},
},
},
},
@@ -306,6 +346,16 @@ func TestCodecsEncodePluginConfig(t *testing.T) {
},
},
},
{
Name: "NodeResourcesLeastAllocated",
Args: runtime.RawExtension{
Object: &v1alpha2.NodeResourcesLeastAllocatedArgs{
Resources: []v1alpha2.ResourceSpec{
{Name: "mem", Weight: 2},
},
},
},
},
{
Name: "OutOfTreePlugin",
Args: runtime.RawExtension{
@@ -349,6 +399,13 @@ profiles:
- Score: 2
Utilization: 1
name: RequestedToCapacityRatio
- args:
apiVersion: kubescheduler.config.k8s.io/v1alpha2
kind: NodeResourcesLeastAllocatedArgs
resources:
- Name: mem
Weight: 2
name: NodeResourcesLeastAllocated
- args:
foo: bar
name: OutOfTreePlugin
@@ -367,6 +424,12 @@ profiles:
HardPodAffinityWeight: 5,
},
},
{
Name: "NodeResourcesMostAllocated",
Args: &config.NodeResourcesMostAllocatedArgs{
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}},
},
},
{
Name: "OutOfTreePlugin",
Args: &runtime.Unknown{
@@ -409,6 +472,13 @@ profiles:
hardPodAffinityWeight: 5
kind: InterPodAffinityArgs
name: InterPodAffinity
- args:
apiVersion: kubescheduler.config.k8s.io/v1alpha2
kind: NodeResourcesMostAllocatedArgs
resources:
- Name: cpu
Weight: 1
name: NodeResourcesMostAllocated
- args:
foo: bar
name: OutOfTreePlugin