You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The kube-scheduler can be configured to enable bin packing of resources along with extended resources using `RequestedToCapacityRatioResourceAllocation` priority function. Priority functions can be used to fine-tune the kube-scheduler as per custom needs.
16
-
17
-
15
+
The kube-scheduler can be configured to enable bin packing of resources along
16
+
with extended resources using `RequestedToCapacityRatioResourceAllocation`
17
+
priority function. Priority functions can be used to fine-tune the
18
+
kube-scheduler as per custom needs.
18
19
19
20
<!-- body -->
20
21
21
22
## Enabling Bin Packing using RequestedToCapacityRatioResourceAllocation
22
23
23
-
Before Kubernetes 1.15, Kube-scheduler used to allow scoring nodes based on the request to capacity ratio of primary resources like CPU and Memory. Kubernetes 1.16 added a new parameter to the priority function that allows the users to specify the resources along with weights for each resource to score nodes based on the request to capacity ratio. This allows users to bin pack extended resources by using appropriate parameters and improves the utilization of scarce resources in large clusters. The behavior of the `RequestedToCapacityRatioResourceAllocation` priority function can be controlled by a configuration option called `requestedToCapacityRatioArguments`. This argument consists of two parameters `shape` and `resources`. Shape allows the user to tune the function as least requested or most requested based on `utilization` and `score` values. Resources
24
-
consists of `name` which specifies the resource to be considered during scoring and `weight` specify the weight of each resource.
25
-
26
-
Below is an example configuration that sets `requestedToCapacityRatioArguments` to bin packing behavior for extended resources `intel.com/foo` and `intel.com/bar`
27
-
28
-
```json
29
-
{
30
-
"kind" : "Policy",
31
-
"apiVersion" : "v1",
32
-
33
-
...
34
-
35
-
"priorities" : [
36
-
37
-
...
24
+
Kubernetes allows the users to specify the resources along with weights for
25
+
each resource to score nodes based on the request to capacity ratio. This
26
+
allows users to bin pack extended resources by using appropriate parameters
27
+
and improves the utilization of scarce resources in large clusters. The
28
+
behavior of the `RequestedToCapacityRatioResourceAllocation` priority function
29
+
can be controlled by a configuration option called
30
+
`requestedToCapacityRatioArguments`. This argument consists of two parameters
31
+
`shape` and `resources`. The `shape` parameter allows the user to tune the
32
+
function as least requested or most requested based on `utilization` and
33
+
`score` values. The `resources` parameter consists of `name` of the resource
34
+
to be considered during scoring and `weight` specify the weight of each
35
+
resource.
36
+
37
+
Below is an example configuration that sets
38
+
`requestedToCapacityRatioArguments` to bin packing behavior for extended
39
+
resources `intel.com/foo` and `intel.com/bar`.
38
40
39
-
{
40
-
"name": "RequestedToCapacityRatioPriority",
41
-
"weight": 2,
42
-
"argument": {
43
-
"requestedToCapacityRatioArguments": {
44
-
"shape": [
45
-
{"utilization": 0, "score": 0},
46
-
{"utilization": 100, "score": 10}
47
-
],
48
-
"resources": [
49
-
{"name": "intel.com/foo", "weight": 3},
50
-
{"name": "intel.com/bar", "weight": 5}
51
-
]
52
-
}
53
-
}
54
-
}
55
-
],
56
-
}
41
+
```yaml
42
+
apiVersion: v1
43
+
kind: Policy
44
+
# ...
45
+
priorities:
46
+
# ...
47
+
- name: RequestedToCapacityRatioPriority
48
+
weight: 2
49
+
argument:
50
+
requestedToCapacityRatioArguments:
51
+
shape:
52
+
- utilization: 0
53
+
score: 0
54
+
- utilization: 100
55
+
score: 10
56
+
resources:
57
+
- name: intel.com/foo
58
+
weight: 3
59
+
- name: intel.com/bar
60
+
weight: 5
57
61
```
58
62
59
63
**This feature is disabled by default**
60
64
61
-
### Tuning RequestedToCapacityRatioResourceAllocation Priority Function
65
+
### Tuning the Priority Function
62
66
63
-
`shape` is used to specify the behavior of the `RequestedToCapacityRatioPriority` function.
67
+
`shape` is used to specify the behavior of the
68
+
`RequestedToCapacityRatioPriority`function.
64
69
65
70
```yaml
66
-
{"utilization": 0, "score": 0},
67
-
{"utilization": 100, "score": 10}
71
+
shape:
72
+
- utilization: 0
73
+
score: 0
74
+
- utilization: 100
75
+
score: 10
68
76
```
69
77
70
-
The above arguments give the node a score of 0 if utilization is 0% and 10 for utilization 100%, thus enabling bin packing behavior. To enable least requested the score value must be reversed as follows.
78
+
The above arguments give the node a `score` of 0 if `utilization` is 0% and 10 for
79
+
`utilization`100%, thus enabling bin packing behavior. To enable least
80
+
requested the score value must be reversed as follows.
71
81
72
82
```yaml
73
-
{"utilization": 0, "score": 100},
74
-
{"utilization": 100, "score": 0}
83
+
shape:
84
+
- utilization: 0
85
+
score: 100
86
+
- utilization: 100
87
+
score: 0
75
88
```
76
89
77
-
`resources` is an optional parameter which by defaults is set to:
90
+
`resources` is an optional parameter which defaults to:
78
91
79
92
``` yaml
80
-
"resources": [
81
-
{"name": "CPU", "weight": 1},
82
-
{"name": "Memory", "weight": 1}
83
-
]
93
+
resources:
94
+
- name: CPU
95
+
weight: 1
96
+
- name: Memory
97
+
weight: 1
84
98
```
85
99
86
100
It can be used to add extended resources as follows:
87
101
88
102
```yaml
89
-
"resources": [
90
-
{"name": "intel.com/foo", "weight": 5},
91
-
{"name": "CPU", "weight": 3},
92
-
{"name": "Memory", "weight": 1}
93
-
]
103
+
resources:
104
+
- name: intel.com/foo
105
+
weight: 5
106
+
- name: CPU
107
+
weight: 3
108
+
- name: Memory
109
+
weight: 1
94
110
```
95
111
96
-
The weight parameter is optional and is set to 1 if not specified. Also, the weight cannot be set to a negative value.
112
+
The `weight` parameter is optional and is set to 1 if not specified. Also, the
113
+
`weight`cannot be set to a negative value.
97
114
98
-
### How the RequestedToCapacityRatioResourceAllocation Priority Function Scores Nodes
115
+
### Node scoring for capacity allocation
99
116
100
117
This section is intended for those who want to understand the internal details
101
118
of this feature.
102
119
Below is an example of how the node score is calculated for a given set of values.
103
120
104
-
```
105
-
Requested Resources
121
+
Requested resources:
106
122
123
+
```
107
124
intel.com/foo : 2
108
125
Memory: 256MB
109
126
CPU: 2
127
+
```
110
128
111
-
Resource Weights
129
+
Resource weights:
112
130
131
+
```
113
132
intel.com/foo : 5
114
133
Memory: 1
115
134
CPU: 3
135
+
```
116
136
117
137
FunctionShapePoint {{0, 0}, {100, 10}}
118
138
119
-
Node 1 Spec
139
+
Node 1 spec:
120
140
141
+
```
121
142
Available:
122
-
intel.com/foo: 4
123
-
Memory : 1 GB
124
-
CPU: 8
143
+
intel.com/foo: 4
144
+
Memory: 1 GB
145
+
CPU: 8
125
146
126
147
Used:
127
-
intel.com/foo: 1
128
-
Memory: 256MB
129
-
CPU: 1
130
-
148
+
intel.com/foo: 1
149
+
Memory: 256MB
150
+
CPU: 1
151
+
```
131
152
132
-
Node Score:
153
+
Node score:
133
154
155
+
```
134
156
intel.com/foo = resourceScoringFunction((2+1),4)
135
157
= (100 - ((4-3)*100/4)
136
158
= (100 - 25)
@@ -152,24 +174,24 @@ CPU = resourceScoringFunction((2+1),8)
0 commit comments