Skip to content

Commit 2c38cb1

Browse files
committed
Tweak page style for resource-bin-packing
1 parent 45da282 commit 2c38cb1

File tree

1 file changed

+105
-79
lines changed

1 file changed

+105
-79
lines changed

content/en/docs/concepts/scheduling-eviction/resource-bin-packing.md

Lines changed: 105 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -12,125 +12,147 @@ weight: 50
1212

1313
{{< feature-state for_k8s_version="v1.16" state="alpha" >}}
1414

15-
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.
1819

1920
<!-- body -->
2021

2122
## Enabling Bin Packing using RequestedToCapacityRatioResourceAllocation
2223

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`.
3840

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
5761
```
5862
5963
**This feature is disabled by default**
6064
61-
### Tuning RequestedToCapacityRatioResourceAllocation Priority Function
65+
### Tuning the Priority Function
6266
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.
6469

6570
```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
6876
```
6977

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.
7181

7282
```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
7588
```
7689

77-
`resources` is an optional parameter which by defaults is set to:
90+
`resources` is an optional parameter which defaults to:
7891

7992
``` 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
8498
```
8599

86100
It can be used to add extended resources as follows:
87101

88102
```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
94110
```
95111

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.
97114

98-
### How the RequestedToCapacityRatioResourceAllocation Priority Function Scores Nodes
115+
### Node scoring for capacity allocation
99116

100117
This section is intended for those who want to understand the internal details
101118
of this feature.
102119
Below is an example of how the node score is calculated for a given set of values.
103120

104-
```
105-
Requested Resources
121+
Requested resources:
106122

123+
```
107124
intel.com/foo : 2
108125
Memory: 256MB
109126
CPU: 2
127+
```
110128

111-
Resource Weights
129+
Resource weights:
112130

131+
```
113132
intel.com/foo : 5
114133
Memory: 1
115134
CPU: 3
135+
```
116136

117137
FunctionShapePoint {{0, 0}, {100, 10}}
118138

119-
Node 1 Spec
139+
Node 1 spec:
120140

141+
```
121142
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
125146
126147
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+
```
131152

132-
Node Score:
153+
Node score:
133154

155+
```
134156
intel.com/foo = resourceScoringFunction((2+1),4)
135157
= (100 - ((4-3)*100/4)
136158
= (100 - 25)
@@ -152,24 +174,24 @@ CPU = resourceScoringFunction((2+1),8)
152174
153175
NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3)
154176
= 5
177+
```
155178

179+
Node 2 spec:
156180

157-
Node 2 Spec
158-
181+
```
159182
Available:
160-
intel.com/foo: 8
161-
Memory: 1GB
162-
CPU: 8
163-
183+
intel.com/foo: 8
184+
Memory: 1GB
185+
CPU: 8
164186
Used:
187+
intel.com/foo: 2
188+
Memory: 512MB
189+
CPU: 6
190+
```
165191

166-
intel.com/foo: 2
167-
Memory: 512MB
168-
CPU: 6
169-
170-
171-
Node Score:
192+
Node score:
172193

194+
```
173195
intel.com/foo = resourceScoringFunction((2+2),8)
174196
= (100 - ((8-4)*100/8)
175197
= (100 - 50)
@@ -194,4 +216,8 @@ NodeScore = (5 * 5) + (7 * 1) + (10 * 3) / (5 + 1 + 3)
194216
195217
```
196218

219+
## {{% heading "whatsnext" %}}
220+
221+
- Read more about the [scheduling framework](/docs/concepts/scheduling-eviction/scheduling-framework/)
222+
- Read more about [scheduler configuration](/docs/reference/scheduling/config/)
197223

0 commit comments

Comments
 (0)