@@ -16,7 +16,7 @@ weight: 60
16
16
17
17
<!-- overview -->
18
18
19
- {{< feature-state for_k8s_version="1 .19" state="stable" >}}
19
+ {{< feature-state for_k8s_version="v1 .19" state="stable" >}}
20
20
21
21
<!--
22
22
The scheduling framework is a pluggable architecture for the Kubernetes scheduler.
@@ -32,6 +32,8 @@ framework.
32
32
请参考[ 调度框架的设计提案] ( https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/624-scheduling-framework/README.md )
33
33
获取框架设计的更多技术信息。
34
34
35
+ [ kep ] : https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/624-scheduling-framework/README.md
36
+
35
37
<!-- body -->
36
38
37
39
<!--
@@ -110,11 +112,11 @@ stateful tasks.
110
112
111
113
<!--
112
114
These plugins are used to sort Pods in the scheduling queue. A queue sort plugin
113
- essentially provides a `less (Pod1, Pod2)` function. Only one queue sort
115
+ essentially provides a `Less (Pod1, Pod2)` function. Only one queue sort
114
116
plugin may be enabled at a time.
115
117
-->
116
118
这些插件用于对调度队列中的 Pod 进行排序。
117
- 队列排序插件本质上提供 ` less (Pod1, Pod2)` 函数。
119
+ 队列排序插件本质上提供 ` Less (Pod1, Pod2)` 函数。
118
120
一次只能启动一个队列插件。
119
121
120
122
<!--
@@ -215,7 +217,7 @@ many blinking lights they have.
215
217
216
218
``` go
217
219
func ScoreNode (_ *v1 .pod , n *v1 .Node ) (int , error ) {
218
- return getBlinkingLightCount (n)
220
+ return getBlinkingLightCount (n)
219
221
}
220
222
```
221
223
@@ -229,13 +231,13 @@ extension point.
229
231
230
232
``` go
231
233
func NormalizeScores (scores map [string ]int ) {
232
- highest := 0
233
- for _ , score := range scores {
234
- highest = max (highest, score)
235
- }
236
- for node , score := range scores {
237
- scores[node] = score*NodeScoreMax/highest
238
- }
234
+ highest := 0
235
+ for _ , score := range scores {
236
+ highest = max (highest, score)
237
+ }
238
+ for node , score := range scores {
239
+ scores[node] = score*NodeScoreMax/highest
240
+ }
239
241
}
240
242
```
241
243
@@ -245,31 +247,62 @@ aborted.
245
247
-->
246
248
如果任何 NormalizeScore 插件返回错误,则调度阶段将终止。
247
249
250
+ {{< note >}}
248
251
<!--
249
252
Plugins wishing to perform "pre-reserve" work should use the
250
253
NormalizeScore extension point.
251
254
-->
252
- {{< note >}}
253
255
希望执行“预保留”工作的插件应该使用 NormalizeScore 扩展点。
254
256
{{< /note >}}
255
257
258
+ ### Reserve {#reserve}
259
+
256
260
<!--
257
- ### Reserve
261
+ A plugin that implements the Reserve extension has two methods, namely `Reserve`
262
+ and `Unreserve`, that back two informational scheduling phases called Reserve
263
+ and Unreserve, respectively. Plugins which maintain runtime state (aka "stateful
264
+ plugins") should use these phases to be notified by the scheduler when resources
265
+ on a node are being reserved and unreserved for a given Pod.
258
266
-->
259
- ### Reserve
267
+ 实现了 Reserve 扩展的插件,拥有两个方法,即 ` Reserve ` 和 ` Unreserve ` ,
268
+ 他们分别支持两个名为 Reserve 和 Unreserve 的信息处理性质的调度阶段。
269
+ 维护运行时状态的插件(又称 "有状态插件")应该使用这两个阶段,
270
+ 以便在节点上的资源被保留和未保留给特定的 Pod 时得到调度器的通知。
260
271
261
272
<!--
262
- This is an informational extension point. Plugins which maintain runtime state
263
- (aka "stateful plugins") should use this extension point to be notified by the
264
- scheduler when resources on a node are being reserved for a given Pod. This
265
- happens before the scheduler actually binds the Pod to the Node, and it exists
266
- to prevent race conditions while the scheduler waits for the bind to succeed.
273
+ The Reserve phase happens before the scheduler actually binds a Pod to its
274
+ designated node. It exists to prevent race conditions while the scheduler waits
275
+ for the bind to succeed. The `Reserve` method of each Reserve plugin may succeed
276
+ or fail; if one `Reserve` method call fails, subsequent plugins are not executed
277
+ and the Reserve phase is considered to have failed. If the `Reserve` method of
278
+ all plugins succeed, the Reserve phase is considered to be successful and the
279
+ rest of the scheduling cycle and the binding cycle are executed.
267
280
-->
268
- Reserve 是一个信息性的扩展点。
269
- 管理运行时状态的插件(也成为“有状态插件”)应该使用此扩展点,以便
270
- 调度器在节点给指定 Pod 预留了资源时能够通知该插件。
271
- 这是在调度器真正将 Pod 绑定到节点之前发生的,并且它存在是为了防止
272
- 在调度器等待绑定成功时发生竞争情况。
281
+ Reserve 阶段发生在调度器实际将一个 Pod 绑定到其指定节点之前。
282
+ 它的存在是为了防止在调度器等待绑定成功时发生竞争情况。
283
+ 每个 Reserve 插件的 ` Reserve ` 方法可能成功,也可能失败;
284
+ 如果一个 ` Reserve ` 方法调用失败,后面的插件就不会被执行,Reserve 阶段被认为失败。
285
+ 如果所有插件的 ` Reserve ` 方法都成功了,Reserve 阶段就被认为是成功的,
286
+ 剩下的调度周期和绑定周期就会被执行。
287
+
288
+ <!--
289
+ The Unreserve phase is triggered if the Reserve phase or a later phase fails.
290
+ When this happens, the `Unreserve` method of **all** Reserve plugins will be
291
+ executed in the reverse order of `Reserve` method calls. This phase exists to
292
+ clean up the state associated with the reserved Pod.
293
+ -->
294
+ 如果 Reserve 阶段或后续阶段失败了,则触发 Unreserve 阶段。
295
+ 发生这种情况时,** 所有** Reserve 插件的 ` Unreserve ` 方法将按照
296
+ ` Reserve ` 方法调用的相反顺序执行。
297
+ 这个阶段的存在是为了清理与保留的 Pod 相关的状态。
298
+
299
+ {{< caution >}}
300
+ <!--
301
+ The implementation of the `Unreserve` method in Reserve plugins must be
302
+ idempotent and may not fail.
303
+ -->
304
+ Reserve 插件中 ` Unreserve ` 方法的实现必须是幂等的,并且不能失败。
305
+ {{< /caution >}}
273
306
274
307
<!--
275
308
This is the last step in a scheduling cycle. Once a Pod is in the reserved
@@ -303,42 +336,41 @@ _Permit_ 插件在每个 Pod 调度周期的最后调用,用于防止或延迟
303
336
<!--
304
337
1. **deny** \
305
338
If any Permit plugin denies a Pod, it is returned to the scheduling queue.
306
- This will trigger [ Unreserve](#unreserve) plugins .
339
+ This will trigger the Unreserve phase in [Reserve plugins ](#reserve) .
307
340
-->
308
341
1 . ** 拒绝** \
309
342
如果任何 Permit 插件拒绝 Pod,则该 Pod 将被返回到调度队列。
310
- 这将触发[ Unreserve ] ( #unreserve ) 插件 。
343
+ 这将触发 [ Reserve 插件 ] ( #reserve ) 中的 Unreserve 阶段 。
311
344
312
345
<!--
313
346
1. **wait** (with a timeout) \
314
347
If a Permit plugin returns "wait", then the Pod is kept in an internal "waiting"
315
348
Pods list, and the binding cycle of this Pod starts but directly blocks until it
316
- gets [ approved](#frameworkhandle) . If a timeout occurs, **wait** becomes **deny**
317
- and the Pod is returned to the scheduling queue, triggering [Unreserve](#unreserve)
318
- plugins.
349
+ gets approved. If a timeout occurs, **wait** becomes **deny**
350
+ and the Pod is returned to the scheduling queue, triggering the
351
+ Unreserve phase in [Reserve plugins](#reserve) .
319
352
-->
320
353
1 . ** 等待** (带有超时) \
321
354
如果一个 Permit 插件返回 “等待” 结果,则 Pod 将保持在一个内部的 “等待中”
322
- 的 Pod 列表,同时该 Pod 的绑定周期启动时即直接阻塞直到得到
323
- [ 批准] ( #frameworkhandle ) 。如果超时发生,** 等待** 变成 ** 拒绝** ,并且 Pod
324
- 将返回调度队列,从而触发 [ Unreserve] ( #unreserve ) 插件。
325
-
355
+ 的 Pod 列表,同时该 Pod 的绑定周期启动时即直接阻塞直到得到批准。
356
+ 如果超时发生,** 等待** 变成 ** 拒绝** ,并且 Pod
357
+ 将返回调度队列,从而触发 [ Reserve 插件] ( #reserve ) 中的 Unreserve 阶段。
326
358
359
+ {{< note >}}
327
360
<!--
328
361
While any plugin can access the list of "waiting" Pods and approve them
329
362
(see [`FrameworkHandle`](https://git.k8s.io/enhancements/keps/sig-scheduling/624-scheduling-framework#frameworkhandle)), we expect only the permit
330
363
plugins to approve binding of reserved Pods that are in "waiting" state. Once a Pod
331
364
is approved, it is sent to the [PreBind](#pre-bind) phase.
332
365
-->
333
- {{< note >}}
334
366
尽管任何插件可以访问 “等待中” 状态的 Pod 列表并批准它们
335
367
(查看 [ ` FrameworkHandle ` ] ( https://git.k8s.io/enhancements/keps/sig-scheduling/624-scheduling-framework#frameworkhandle ) )。
336
368
我们期望只有允许插件可以批准处于 “等待中” 状态的预留 Pod 的绑定。
337
369
一旦 Pod 被批准了,它将发送到 [ PreBind] ( #pre-bind ) 阶段。
338
370
{{< /note >}}
339
371
340
372
<!--
341
- ### Pre-bind {#pre-bind}
373
+ ### PreBind {#pre-bind}
342
374
-->
343
375
### PreBind {#pre-bind}
344
376
@@ -352,10 +384,10 @@ target node before allowing the Pod to run there.
352
384
将其挂载到目标节点上。
353
385
354
386
<!--
355
- If any PreBind plugin returns an error, the Pod is [rejected](#unreserve ) and
387
+ If any PreBind plugin returns an error, the Pod is [rejected](#reserve ) and
356
388
returned to the scheduling queue.
357
389
-->
358
- 如果任何 PreBind 插件返回错误,则 Pod 将被 [ 拒绝] ( #unreserve ) 并且
390
+ 如果任何 PreBind 插件返回错误,则 Pod 将被 [ 拒绝] ( #reserve ) 并且
359
391
退回到调度队列中。
360
392
361
393
<!--
@@ -422,26 +454,26 @@ interfaces have the following form.
422
454
423
455
``` go
424
456
type Plugin interface {
425
- Name () string
457
+ Name () string
426
458
}
427
459
428
460
type QueueSortPlugin interface {
429
- Plugin
430
- Less (*v1.pod , *v1.pod ) bool
461
+ Plugin
462
+ Less (*v1.pod , *v1.pod ) bool
431
463
}
432
464
433
465
type PreFilterPlugin interface {
434
- Plugin
435
- PreFilter (context.Context , *framework.CycleState , *v1.pod ) error
466
+ Plugin
467
+ PreFilter (context.Context , *framework.CycleState , *v1.pod ) error
436
468
}
437
469
438
470
// ...
439
471
```
440
472
441
473
<!--
442
- # Plugin Configuration
474
+ ## Plugin configuration
443
475
-->
444
- # 插件配置
476
+ ## 插件配置
445
477
446
478
<!--
447
479
You can enable or disable plugins in the scheduler configuration. If you are using
@@ -471,5 +503,3 @@ Learn more at [multiple profiles](/docs/reference/scheduling/config/#multiple-pr
471
503
如果你正在使用 Kubernetes v1.18 或更高版本,你可以将一组插件设置为
472
504
一个调度器配置文件,然后定义不同的配置文件来满足各类工作负载。
473
505
了解更多关于[ 多配置文件] ( /zh-cn/docs/reference/scheduling/config/#multiple-profiles ) 。
474
-
475
-
0 commit comments