Skip to content

Commit b11335c

Browse files
authored
Merge pull request #34248 from tengqm/zh-34221-concepts-2
[zh] Resync concepts pages after lang renaming (concepts-2)
2 parents 5c2eb69 + 0d82c43 commit b11335c

File tree

3 files changed

+271
-101
lines changed

3 files changed

+271
-101
lines changed

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

Lines changed: 160 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -17,75 +17,119 @@ weight: 80
1717

1818
<!-- overview -->
1919

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 -->
2129

2230
<!--
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:
2438
-->
39+
## 使用 MostAllocated 策略启用资源装箱 {#enabling-bin-packing-using-mostallocated-strategy}
2540

26-
使用 `RequestedToCapacityRatioResourceAllocation` 优先级函数,可以将 kube-scheduler
27-
配置为支持包含扩展资源在内的资源装箱操作。
28-
优先级函数可用于根据自定义需求微调 kube-scheduler 。
41+
`MostAllocated` 策略基于资源的利用率来为节点计分,优选分配比率较高的节点。
42+
针对每种资源类型,你可以设置一个权重值以改变其对节点得分的影响。
2943

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 文档。
3174

3275
<!--
33-
## Enabling Bin Packing using RequestedToCapacityRatioResourceAllocation
76+
## Enabling bin packing using RequestedToCapacityRatio
3477

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
3679
each resource to score nodes based on the request to capacity ratio. This
3780
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`
4287
parameter allows the user to tune the function as least requested or most
4388
requested based on `utilization` and `score` values. The `resources` parameter
4489
consists of `name` of the resource to be considered during scoring and `weight`
4590
specify the weight of each resource.
46-
4791
-->
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`。
61104

62105
<!--
63106
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.
66109
-->
67-
68-
以下是一个配置示例,该配置将 `requestedToCapacityRatioArguments` 设置为对扩展资源
69-
`intel.com/foo``intel.com/bar` 的装箱行为
110+
下面是一个配置示例,使用 `requestedToCapacityRatio` 字段为扩展资源 `intel.com/foo`
111+
和 `intel.com/bar` 设置装箱行为:
70112

71113
```yaml
72114
apiVersion: kubescheduler.config.k8s.io/v1beta3
73115
kind: KubeSchedulerConfiguration
74116
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
89133
```
90134

91135
<!--
@@ -94,22 +138,24 @@ flag `--config=/path/to/config/file` will pass the configuration to the
94138
scheduler.
95139
-->
96140
使用 kube-scheduler 标志 `--config=/path/to/config/file`
97-
引用 `KubeSchedulerConfiguration` 文件将配置传递给调度器
141+
引用 `KubeSchedulerConfiguration` 文件,可以将配置传递给调度器
98142

99143
<!--
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).
101146
-->
102-
103-
**默认情况下此功能处于被禁用状态**
147+
要进一步了解其它参数及其默认配置,可以参阅
148+
[`NodeResourcesFitArgs`](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs)
149+
的 API 文档。
104150

105151
<!--
106-
### Tuning RequestedToCapacityRatioResourceAllocation Priority Function
152+
### Tuning the score function
107153

108-
`shape` is used to specify the behavior of the `RequestedToCapacityRatioPriority` function.
154+
`shape` is used to specify the behavior of the `RequestedToCapacityRatio` function.
109155
-->
110-
### 调整 RequestedToCapacityRatioResourceAllocation 优先级函数
156+
### 调整计分函数 {#tuning-the-score-function}
111157

112-
`shape` 用于指定 `RequestedToCapacityRatioPriority` 函数的行为。
158+
`shape` 用于指定 `RequestedToCapacityRatio` 函数的行为。
113159

114160
```yaml
115161
shape:
@@ -120,9 +166,10 @@ shape:
120166
```
121167

122168
<!--
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.
124172
-->
125-
126173
上面的参数在 `utilization` 为 0% 时给节点评分为 0,在 `utilization` 为
127174
100% 时给节点评分为 10,因此启用了装箱行为。
128175
要启用最少请求(least requested)模式,必须按如下方式反转得分值。
@@ -151,7 +198,7 @@ resources:
151198
<!--
152199
It can be used to add extended resources as follows:
153200
-->
154-
它可以用来添加扩展资源,如下所示
201+
它可以像下面这样用来添加扩展资源
155202

156203
```yaml
157204
resources:
@@ -164,10 +211,11 @@ resources:
164211
```
165212

166213
<!--
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.
168216
-->
169-
weight 参数是可选的,如果未指定,则设置为 1。
170-
同时,weight 不能设置为负值。
217+
`weight` 参数是可选的,如果未指定,则设置为 1。
218+
同时,`weight` 不能设置为负值。
171219

172220
<!--
173221
### Node scoring for capacity allocation
@@ -176,29 +224,43 @@ This section is intended for those who want to understand the internal details
176224
of this feature.
177225
Below is an example of how the node score is calculated for a given set of values.
178226
-->
179-
180-
### 节点容量分配的评分
227+
### 节点容量分配的评分 {#node-scoring-for-capacity-allocation}
181228

182229
本节适用于希望了解此功能的内部细节的人员。
183230
以下是如何针对给定的一组值来计算节点得分的示例。
184231

185-
```
186-
请求的资源
232+
<!--
233+
Requested resources:
234+
-->
235+
请求的资源:
187236

237+
```
188238
intel.com/foo : 2
189239
memory: 256MB
190240
cpu: 2
241+
```
191242
192-
资源权重
243+
<!--
244+
Resource weights:
245+
-->
246+
资源权重:
193247
248+
```
194249
intel.com/foo : 5
195250
memory: 1
196251
cpu: 3
252+
```
197253
254+
```
198255
FunctionShapePoint {{0, 0}, {100, 10}}
256+
```
199257
200-
节点 Node 1 配置
258+
<!--
259+
Node 1 spec:
260+
-->
261+
节点 1 配置:
201262
263+
```
202264
可用:
203265
intel.com/foo : 4
204266
memory : 1 GB
@@ -208,34 +270,43 @@ FunctionShapePoint {{0, 0}, {100, 10}}
208270
intel.com/foo: 1
209271
memory: 256MB
210272
cpu: 1
273+
```
211274
275+
<!--
276+
Node score:
277+
-->
212278
节点得分:
213279
280+
```
214281
intel.com/foo = resourceScoringFunction((2+1),4)
215282
= (100 - ((4-3)*100/4)
216283
= (100 - 25)
217-
= 75
218-
= rawScoringFunction(75)
219-
= 7
284+
= 75 # requested + used = 75% * available
285+
= rawScoringFunction(75)
286+
= 7 # floor(75/10)
220287

221288
memory = resourceScoringFunction((256+256),1024)
222289
= (100 -((1024-512)*100/1024))
223-
= 50
290+
= 50 # requested + used = 50% * available
224291
= rawScoringFunction(50)
225-
= 5
292+
= 5 # floor(50/10)
226293

227294
cpu = resourceScoringFunction((2+1),8)
228295
= (100 -((8-3)*100/8))
229-
= 37.5
296+
= 37.5 # requested + used = 37.5% * available
230297
= rawScoringFunction(37.5)
231-
= 3
298+
= 3 # floor(37.5/10)
232299

233300
NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3)
234301
= 5
302+
```
235303
304+
<!--
305+
Node 2 spec:
306+
-->
307+
节点 2 配置:
236308
237-
节点 Node 2 配置
238-
309+
```
239310
可用:
240311
intel.com/foo: 8
241312
memory: 1GB
@@ -245,9 +316,14 @@ NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3)
245316
intel.com/foo: 2
246317
memory: 512MB
247318
cpu: 6
319+
```
248320
321+
<!--
322+
Node score:
323+
-->
249324
节点得分:
250325
326+
```
251327
intel.com/foo = resourceScoringFunction((2+2),8)
252328
= (100 - ((8-4)*100/8)
253329
= (100 - 50)
@@ -270,3 +346,13 @@ cpu = resourceScoringFunction((2+6),8)
270346
NodeScore = (5 * 5) + (7 * 1) + (10 * 3) / (5 + 1 + 3)
271347
= 7
272348
```
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

Comments
 (0)