@@ -17,75 +17,119 @@ weight: 80
17
17
18
18
<!-- overview -->
19
19
20
- {{< feature-state for_k8s_version="1.16" state="alpha" >}}
20
+ <!--
21
+ In the [scheduling-plugin](/docs/reference/scheduling/config/#scheduling-plugins) `NodeResourcesFit` of kube-scheduler, there are two
22
+ scoring strategies that support the bin packing of resources: `MostAllocated` and `RequestedToCapacityRatio`.
23
+ -->
24
+ 在 kube-scheduler 的[ 调度插件] ( /zh-cn/docs/reference/scheduling/config/#scheduling-plugins )
25
+ ` NodeResourcesFit ` 中存在两种支持资源装箱(bin packing)的策略:` MostAllocated ` 和
26
+ ` RequestedToCapacityRatio ` 。
27
+
28
+ <!-- body -->
21
29
22
30
<!--
23
- 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.
31
+ ## Enabling bin packing using MostAllocated strategy
32
+
33
+ The `MostAllocated` strategy scores the nodes based on the utilization of resources, favoring the ones with higher allocation.
34
+ For each resource type, you can set a weight to modify its influence in the node score.
35
+
36
+ To set the `MostAllocated` strategy for the `NodeResourcesFit` plugin, use a
37
+ [scheduler configuration](/docs/reference/scheduling/config) similar to the following:
24
38
-->
39
+ ## 使用 MostAllocated 策略启用资源装箱 {#enabling-bin-packing-using-mostallocated-strategy}
25
40
26
- 使用 ` RequestedToCapacityRatioResourceAllocation ` 优先级函数,可以将 kube-scheduler
27
- 配置为支持包含扩展资源在内的资源装箱操作。
28
- 优先级函数可用于根据自定义需求微调 kube-scheduler 。
41
+ ` MostAllocated ` 策略基于资源的利用率来为节点计分,优选分配比率较高的节点。
42
+ 针对每种资源类型,你可以设置一个权重值以改变其对节点得分的影响。
29
43
30
- <!-- body -->
44
+ 要为插件 ` NodeResourcesFit ` 设置 ` MostAllocated ` 策略,
45
+ 可以使用一个类似于下面这样的[ 调度器配置] ( /zh-cn/docs/reference/scheduling/config/ ) :
46
+
47
+ ``` yaml
48
+ apiVersion : kubescheduler.config.k8s.io/v1beta3
49
+ kind : KubeSchedulerConfiguration
50
+ profiles :
51
+ - pluginConfig :
52
+ - args :
53
+ scoringStrategy :
54
+ resources :
55
+ - name : cpu
56
+ weight : 1
57
+ - name : memory
58
+ weight : 1
59
+ - name : intel.com/foo
60
+ weight : 3
61
+ - name : intel.com/bar
62
+ weight : 3
63
+ type : MostAllocated
64
+ name : NodeResourcesFit
65
+ ` ` `
66
+
67
+ <!--
68
+ To learn more about other parameters and their default configuration, see the API documentation for
69
+ [` NodeResourcesFitArgs`](/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs).
70
+ -->
71
+ 要进一步了解其它参数及其默认配置,请参阅
72
+ [`NodeResourcesFitArgs`](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs)
73
+ 的 API 文档。
31
74
32
75
<!--
33
- ## Enabling Bin Packing using RequestedToCapacityRatioResourceAllocation
76
+ # # Enabling bin packing using RequestedToCapacityRatio
34
77
35
- Kubernetes allows the users to specify the resources along with weights for
78
+ The `RequestedToCapacityRatio` strategy allows the users to specify the resources along with weights for
36
79
each resource to score nodes based on the request to capacity ratio. This
37
80
allows users to bin pack extended resources by using appropriate parameters
38
- and improves the utilization of scarce resources in large clusters. The
39
- behavior of the `RequestedToCapacityRatioResourceAllocation` priority function
40
- can be controlled by a configuration option called `RequestedToCapacityRatioArgs`.
41
- This argument consists of two parameters `shape` and `resources`. The `shape`
81
+ to improve the utilization of scarce resources in large clusters. It favors nodes according to a
82
+ configured function of the allocated resources. The behavior of the `RequestedToCapacityRatio` in
83
+ the `NodeResourcesFit` score function can be controlled by the
84
+ [scoringStrategy](/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-ScoringStrategy) field.
85
+ Within the `scoringStrategy` field, you can configure two parameters : ` requestedToCapacityRatioParam` and
86
+ ` resources` . The `shape` in `requestedToCapacityRatioParam`
42
87
parameter allows the user to tune the function as least requested or most
43
88
requested based on `utilization` and `score` values. The `resources` parameter
44
89
consists of `name` of the resource to be considered during scoring and `weight`
45
90
specify the weight of each resource.
46
-
47
91
-->
48
-
49
- ## 使用 RequestedToCapacityRatioResourceAllocation 启用装箱
50
-
51
- Kubernetes 允许用户指定资源以及每类资源的权重,
52
- 以便根据请求数量与可用容量之比率为节点评分。
53
- 这就使得用户可以通过使用适当的参数来对扩展资源执行装箱操作,从而提高了大型集群中稀缺资源的利用率。
54
- ` RequestedToCapacityRatioResourceAllocation ` 优先级函数的行为可以通过名为
55
- ` RequestedToCapacityRatioArgs ` 的配置选项进行控制。
56
- 该标志由两个参数 ` shape ` 和 ` resources ` 组成。
57
- ` shape ` 允许用户根据 ` utilization ` 和 ` score ` 值将函数调整为
58
- 最少请求(least requested)或最多请求(most requested)计算。
59
- ` resources ` 包含由 ` name ` 和 ` weight ` 组成,` name ` 指定评分时要考虑的资源,
60
- ` weight ` 指定每种资源的权重。
92
+ # # 使用 RequestedToCapacityRatio 策略来启用资源装箱 {#enabling-bin-packing-using-requestedtocapacityratio}
93
+
94
+ ` RequestedToCapacityRatio` 策略允许用户基于请求值与容量的比率,针对参与节点计分的每类资源设置权重。
95
+ 这一策略是的用户可以使用合适的参数来对扩展资源执行装箱操作,进而提升大规模集群中稀有资源的利用率。
96
+ 此策略根据所分配资源的一个配置函数来评价节点。
97
+ ` NodeResourcesFit` 计分函数中的 `RequestedToCapacityRatio` 可以通过字段
98
+ [scoringStrategy](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-ScoringStrategy)
99
+ 来控制。
100
+ 在 `scoringStrategy` 字段中,你可以配置两个参数:`requestedToCapacityRatioParam`
101
+ 和 `resources`。`requestedToCapacityRatioParam` 参数中的 `shape`
102
+ 设置使得用户能够调整函数的算法,基于 `utilization` 和 `score` 值计算最少请求或最多请求。
103
+ ` resources` 参数中包含计分过程中需要考虑的资源的 `name`,以及用来设置每种资源权重的 `weight`。
61
104
62
105
<!--
63
106
Below is an example configuration that sets
64
- `requestedToCapacityRatioArguments` to bin packing behavior for extended
65
- resources `intel.com/foo` and `intel.com/bar` .
107
+ the bin packing behavior for extended resources `intel.com/foo` and `intel.com/bar`
108
+ using the `requestedToCapacityRatio` field .
66
109
-->
67
-
68
- 以下是一个配置示例,该配置将 ` requestedToCapacityRatioArguments ` 设置为对扩展资源
69
- ` intel.com/foo ` 和 ` intel.com/bar ` 的装箱行为
110
+ 下面是一个配置示例,使用 `requestedToCapacityRatio` 字段为扩展资源 `intel.com/foo`
111
+ 和 `intel.com/bar` 设置装箱行为:
70
112
71
113
` ` ` yaml
72
114
apiVersion: kubescheduler.config.k8s.io/v1beta3
73
115
kind: KubeSchedulerConfiguration
74
116
profiles:
75
- # ...
76
- pluginConfig :
77
- - name : RequestedToCapacityRatio
78
- args :
79
- shape :
80
- - utilization : 0
81
- score : 10
82
- - utilization : 100
83
- score : 0
84
- resources :
85
- - name : intel.com/foo
86
- weight : 3
87
- - name : intel.com/bar
88
- weight : 5
117
+ - pluginConfig:
118
+ - args:
119
+ scoringStrategy:
120
+ resources:
121
+ - name: intel.com/foo
122
+ weight: 3
123
+ - name: intel.com/bar
124
+ weight: 3
125
+ requestedToCapacityRatioParam:
126
+ shape:
127
+ - utilization: 0
128
+ score: 0
129
+ - utilization: 100
130
+ score: 10
131
+ type: RequestedToCapacityRatio
132
+ name: NodeResourcesFit
89
133
` ` `
90
134
91
135
<!--
@@ -94,22 +138,24 @@ flag `--config=/path/to/config/file` will pass the configuration to the
94
138
scheduler.
95
139
-->
96
140
使用 kube-scheduler 标志 `--config=/path/to/config/file`
97
- 引用 `KubeSchedulerConfiguration` 文件将配置传递给调度器 。
141
+ 引用 `KubeSchedulerConfiguration` 文件,可以将配置传递给调度器 。
98
142
99
143
<!--
100
- **This feature is disabled by default**
144
+ To learn more about other parameters and their default configuration, see the API documentation for
145
+ [`NodeResourcesFitArgs`](/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs).
101
146
-->
102
-
103
- **默认情况下此功能处于被禁用状态**
147
+ 要进一步了解其它参数及其默认配置,可以参阅
148
+ [`NodeResourcesFitArgs`](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs)
149
+ 的 API 文档。
104
150
105
151
<!--
106
- # ## Tuning RequestedToCapacityRatioResourceAllocation Priority Function
152
+ # ## Tuning the score function
107
153
108
- ` shape` is used to specify the behavior of the `RequestedToCapacityRatioPriority ` function.
154
+ ` shape` is used to specify the behavior of the `RequestedToCapacityRatio ` function.
109
155
-->
110
- # ## 调整 RequestedToCapacityRatioResourceAllocation 优先级函数
156
+ # ## 调整计分函数 {#tuning-the-score-function}
111
157
112
- ` shape` 用于指定 `RequestedToCapacityRatioPriority ` 函数的行为。
158
+ ` shape` 用于指定 `RequestedToCapacityRatio ` 函数的行为。
113
159
114
160
` ` ` yaml
115
161
shape:
@@ -120,9 +166,10 @@ shape:
120
166
` ` `
121
167
122
168
<!--
123
- 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.
169
+ The above arguments give the node a `score` of 0 if `utilization` is 0% and 10 for
170
+ ` utilization` 100%, thus enabling bin packing behavior. To enable least
171
+ requested the score value must be reversed as follows.
124
172
-->
125
-
126
173
上面的参数在 `utilization` 为 0% 时给节点评分为 0,在 `utilization` 为
127
174
100% 时给节点评分为 10,因此启用了装箱行为。
128
175
要启用最少请求(least requested)模式,必须按如下方式反转得分值。
@@ -151,7 +198,7 @@ resources:
151
198
<!--
152
199
It can be used to add extended resources as follows :
153
200
-->
154
- 它可以用来添加扩展资源,如下所示 :
201
+ 它可以像下面这样用来添加扩展资源 :
155
202
156
203
` ` ` yaml
157
204
resources:
@@ -164,10 +211,11 @@ resources:
164
211
` ` `
165
212
166
213
<!--
167
- The weight parameter is optional and is set to 1 if not specified. Also, the weight cannot be set to a negative value.
214
+ The `weight` parameter is optional and is set to 1 if not specified. Also, the
215
+ ` weight` cannot be set to a negative value.
168
216
-->
169
- weight 参数是可选的,如果未指定,则设置为 1。
170
- 同时,weight 不能设置为负值。
217
+ ` weight` 参数是可选的,如果未指定,则设置为 1。
218
+ 同时,` weight` 不能设置为负值。
171
219
172
220
<!--
173
221
# ## Node scoring for capacity allocation
@@ -176,29 +224,43 @@ This section is intended for those who want to understand the internal details
176
224
of this feature.
177
225
Below is an example of how the node score is calculated for a given set of values.
178
226
-->
179
-
180
- # ## 节点容量分配的评分
227
+ # ## 节点容量分配的评分 {#node-scoring-for-capacity-allocation}
181
228
182
229
本节适用于希望了解此功能的内部细节的人员。
183
230
以下是如何针对给定的一组值来计算节点得分的示例。
184
231
185
- ```
186
- 请求的资源
232
+ <!--
233
+ Requested resources :
234
+ -->
235
+ 请求的资源:
187
236
237
+ ```
188
238
intel.com/foo : 2
189
239
memory: 256MB
190
240
cpu: 2
241
+ ```
191
242
192
- 资源权重
243
+ <!--
244
+ Resource weights:
245
+ -->
246
+ 资源权重:
193
247
248
+ ```
194
249
intel.com/foo : 5
195
250
memory: 1
196
251
cpu: 3
252
+ ```
197
253
254
+ ```
198
255
FunctionShapePoint {{0, 0}, {100, 10}}
256
+ ```
199
257
200
- 节点 Node 1 配置
258
+ <!--
259
+ Node 1 spec:
260
+ -->
261
+ 节点 1 配置:
201
262
263
+ ```
202
264
可用:
203
265
intel.com/foo : 4
204
266
memory : 1 GB
@@ -208,34 +270,43 @@ FunctionShapePoint {{0, 0}, {100, 10}}
208
270
intel.com/foo: 1
209
271
memory: 256MB
210
272
cpu: 1
273
+ ```
211
274
275
+ <!--
276
+ Node score:
277
+ -->
212
278
节点得分:
213
279
280
+ ```
214
281
intel.com/foo = resourceScoringFunction((2+1),4)
215
282
= (100 - ((4-3)* 100/4)
216
283
= (100 - 25)
217
- = 75
218
- = rawScoringFunction(75)
219
- = 7
284
+ = 75 # requested + used = 75% * available
285
+ = rawScoringFunction(75)
286
+ = 7 # floor(75/10)
220
287
221
288
memory = resourceScoringFunction((256+256),1024)
222
289
= (100 -((1024-512)* 100/1024))
223
- = 50
290
+ = 50 # requested + used = 50% * available
224
291
= rawScoringFunction(50)
225
- = 5
292
+ = 5 # floor(50/10)
226
293
227
294
cpu = resourceScoringFunction((2+1),8)
228
295
= (100 -((8-3)* 100/8))
229
- = 37.5
296
+ = 37.5 # requested + used = 37.5% * available
230
297
= rawScoringFunction(37.5)
231
- = 3
298
+ = 3 # floor(37.5/10)
232
299
233
300
NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3)
234
301
= 5
302
+ ```
235
303
304
+ <!--
305
+ Node 2 spec:
306
+ -->
307
+ 节点 2 配置:
236
308
237
- 节点 Node 2 配置
238
-
309
+ ```
239
310
可用:
240
311
intel.com/foo: 8
241
312
memory: 1GB
@@ -245,9 +316,14 @@ NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3)
245
316
intel.com/foo: 2
246
317
memory: 512MB
247
318
cpu: 6
319
+ ```
248
320
321
+ <!--
322
+ Node score:
323
+ -->
249
324
节点得分:
250
325
326
+ ```
251
327
intel.com/foo = resourceScoringFunction((2+2),8)
252
328
= (100 - ((8-4)* 100/8)
253
329
= (100 - 50)
@@ -270,3 +346,13 @@ cpu = resourceScoringFunction((2+6),8)
270
346
NodeScore = (5 * 5) + (7 * 1) + (10 * 3) / (5 + 1 + 3)
271
347
= 7
272
348
```
349
+
350
+ ## {{% heading "whatsnext" %}}
351
+
352
+ <!--
353
+ - Read more about the [scheduling framework](/docs/concepts/scheduling-eviction/scheduling-framework/)
354
+ - Read more about [scheduler configuration](/docs/reference/scheduling/config/)
355
+ -->
356
+ - 继续阅读[调度器框架](/zh-cn/docs/concepts/scheduling-eviction/scheduling-framework/)
357
+ - 继续阅读[调度器配置](/zh-cn/docs/reference/scheduling/config/)
358
+
0 commit comments