@@ -3,15 +3,12 @@ title: 调度框架
3
3
content_type : concept
4
4
weight : 60
5
5
---
6
-
7
6
<!--
8
- ---
9
7
reviewers:
10
8
- ahg-g
11
9
title: Scheduling Framework
12
10
content_type: concept
13
11
weight: 60
14
- ---
15
12
-->
16
13
17
14
<!-- overview -->
@@ -25,7 +22,6 @@ scheduling "core" lightweight and maintainable. Refer to the [design proposal of
25
22
scheduling framework][kep] for more technical information on the design of the
26
23
framework.
27
24
-->
28
-
29
25
调度框架是面向 Kubernetes 调度器的一种插件架构,
30
26
它为现有的调度器添加了一组新的“插件” API。插件会被编译到调度器之中。
31
27
这些 API 允许大多数调度功能以插件的形式实现,同时使调度“核心”保持简单且可维护。
@@ -39,7 +35,7 @@ framework.
39
35
<!--
40
36
# Framework workflow
41
37
-->
42
- # 框架工作流程
38
+ # 框架工作流程 {#framework-workflow}
43
39
44
40
<!--
45
41
The Scheduling Framework defines a few extension points. Scheduler plugins
@@ -58,7 +54,7 @@ cycle** and the **binding cycle**.
58
54
<!--
59
55
## Scheduling Cycle & Binding Cycle
60
56
-->
61
- ## 调度周期和绑定周期
57
+ ## 调度周期和绑定周期 {#scheduling-cycle-and-binding-cycle}
62
58
63
59
<!--
64
60
The scheduling cycle selects a node for the Pod, and the binding cycle applies
@@ -82,23 +78,27 @@ the queue and retried.
82
78
Pod 将返回队列并重试。
83
79
84
80
<!--
85
- ## Extension points
81
+ ## Interfaces
86
82
-->
87
- ## 扩展点
83
+ ## 接口 {#interfaces}
88
84
89
85
<!--
90
- The following picture shows the scheduling context of a Pod and the extension
91
- points that the scheduling framework exposes. In this picture "Filter" is
92
- equivalent to "Predicate" and "Scoring" is equivalent to "Priority function".
86
+ The following picture shows the scheduling context of a Pod and the interfaces
87
+ that the scheduling framework exposes.
93
88
-->
94
- 下图显示了一个 Pod 的调度上下文以及调度框架公开的扩展点。
95
- 在此图片中,“过滤器”等同于“断言”,“评分”相当于“优先级函数”。
89
+ 下图显示了一个 Pod 的调度上下文以及调度框架公开的接口。
96
90
97
91
<!--
98
- One plugin may register at multiple extension points to perform more complex or
92
+ One plugin may implement multiple interfaces to perform more complex or
99
93
stateful tasks.
100
94
-->
101
- 一个插件可以在多个扩展点处注册,以执行更复杂或有状态的任务。
95
+ 一个插件可能实现多个接口,以执行更为复杂或有状态的任务。
96
+
97
+ <!--
98
+ Some interfaces match the scheduler extension points which can be configured through
99
+ [Scheduler Configuration](/docs/reference/scheduling/config/#extension-points).
100
+ -->
101
+ 某些接口与可以通过[ 调度器配置] ( /zh-cn/docs/reference/scheduling/config/#extension-points ) 来设置的调度器扩展点匹配。
102
102
103
103
<!--
104
104
{{< figure src="/images/docs/scheduling-framework-extensions.png" title="scheduling framework extension points" class="diagram-large">}}
@@ -125,7 +125,45 @@ For more details about how internal scheduler queues work, read
125
125
只有当所有 PreEnqueue 插件返回 ` Success ` 时,Pod 才允许进入活动队列。
126
126
否则,它将被放置在内部无法调度的 Pod 列表中,并且不会获得 ` Unschedulable ` 状态。
127
127
128
- 要了解有关内部调度器队列如何工作的更多详细信息,请阅读 [ kube-scheduler 调度队列] ( https://github.com/kubernetes/community/blob/f03b6d5692bd979f07dd472e7b6836b2dad0fd9b/contributors/devel/sig-scheduling/scheduler_queues.md ) 。
128
+ 要了解有关内部调度器队列如何工作的更多详细信息,请阅读
129
+ [ kube-scheduler 调度队列] ( https://github.com/kubernetes/community/blob/f03b6d5692bd979f07dd472e7b6836b2dad0fd9b/contributors/devel/sig-scheduling/scheduler_queues.md ) 。
130
+
131
+ ### EnqueueExtension
132
+
133
+ <!--
134
+ EnqueueExtension is the interface where the plugin can control
135
+ whether to retry scheduling of Pods rejected by this plugin, based on changes in the cluster.
136
+ Plugins that implement PreEnqueue, PreFilter, Filter, Reserve or Permit should implement this interface.
137
+ -->
138
+ EnqueueExtension 作为一个接口,插件可以在此接口之上根据集群中的变化来控制是否重新尝试调度被此插件拒绝的 Pod。
139
+ 实现 PreEnqueue、PreFilter、Filter、Reserve 或 Permit 的插件应实现此接口。
140
+
141
+ #### QueueingHint
142
+
143
+ {{< feature-state for_k8s_version="v1.28" state="beta" >}}
144
+
145
+ <!--
146
+ QueueingHint is a callback function for deciding whether a Pod can be requeued to the active queue or backoff queue.
147
+ It's executed every time a certain kind of event or change happens in the cluster.
148
+ When the QueueingHint finds that the event might make the Pod schedulable,
149
+ the Pod is put into the active queue or the backoff queue
150
+ so that the scheduler will retry the scheduling of the Pod.
151
+ -->
152
+ QueueingHint 作为一个回调函数,用于决定是否将 Pod 重新排队到活跃队列或回退队列。
153
+ 每当集群中发生某种事件或变化时,此函数就会被执行。
154
+ 当 QueueingHint 发现事件可能使 Pod 可调度时,Pod 将被放入活跃队列或回退队列,
155
+ 以便调度器可以重新尝试调度 Pod。
156
+
157
+ {{< note >}}
158
+ <!--
159
+ QueueingHint evaluation during scheduling is a beta-level feature and is enabled by default in 1.28.
160
+ You can disable it via the
161
+ `SchedulerQueueingHints` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
162
+ -->
163
+ 在调度过程中对 QueueingHint 求值是一个 Beta 级别的特性,在 1.28 中默认被启用。
164
+ 你可以通过 ` SchedulerQueueingHints `
165
+ [ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ ) 来禁用它。
166
+ {{< /note >}}
129
167
130
168
<!--
131
169
### QueueSort {#queue-sort}
@@ -188,20 +226,20 @@ tries to make the pod schedulable by preempting other Pods.
188
226
189
227
<!--
190
228
### PreScore {#pre-score}
191
- -->
229
+ -->
192
230
### PreScore {#pre-score}
193
231
194
232
<!--
195
233
These plugins are used to perform "pre-scoring" work, which generates a sharable
196
234
state for Score plugins to use. If a PreScore plugin returns an error, the
197
235
scheduling cycle is aborted.
198
- -->
236
+ -->
199
237
这些插件用于执行 “前置评分(pre-scoring)” 工作,即生成一个可共享状态供 Score 插件使用。
200
238
如果 PreScore 插件返回错误,则调度周期将终止。
201
239
202
240
<!--
203
241
### Score {#scoring}
204
- -->
242
+ -->
205
243
### Score {#scoring}
206
244
207
245
<!--
@@ -213,8 +251,8 @@ scores from all plugins according to the configured plugin weights.
213
251
-->
214
252
这些插件用于对通过过滤阶段的节点进行排序。调度器将为每个节点调用每个评分插件。
215
253
将有一个定义明确的整数范围,代表最小和最大分数。
216
- 在[ 标准化评分] ( #normalize-scoring ) 阶段之后,调度器将根据配置的插件权重
217
- 合并所有插件的节点分数 。
254
+ 在[ 标准化评分] ( #normalize-scoring ) 阶段之后,
255
+ 调度器将根据配置的插件权重合并所有插件的节点分数 。
218
256
219
257
<!--
220
258
### NormalizeScore {#normalize-scoring}
@@ -280,13 +318,13 @@ NormalizeScore extension point.
280
318
### Reserve {#reserve}
281
319
282
320
<!--
283
- A plugin that implements the Reserve extension has two methods, namely `Reserve`
321
+ A plugin that implements the Reserve interface has two methods, namely `Reserve`
284
322
and `Unreserve`, that back two informational scheduling phases called Reserve
285
323
and Unreserve, respectively. Plugins which maintain runtime state (aka "stateful
286
324
plugins") should use these phases to be notified by the scheduler when resources
287
325
on a node are being reserved and unreserved for a given Pod.
288
326
-->
289
- 实现了 Reserve 扩展的插件 ,拥有两个方法,即 ` Reserve ` 和 ` Unreserve ` ,
327
+ 实现了 Reserve 接口的插件 ,拥有两个方法,即 ` Reserve ` 和 ` Unreserve ` ,
290
328
他们分别支持两个名为 Reserve 和 Unreserve 的信息处理性质的调度阶段。
291
329
维护运行时状态的插件(又称 "有状态插件")应该使用这两个阶段,
292
330
以便在节点上的资源被保留和未保留给特定的 Pod 时得到调度器的通知。
@@ -360,7 +398,7 @@ _Permit_ 插件在每个 Pod 调度周期的最后调用,用于防止或延迟
360
398
If any Permit plugin denies a Pod, it is returned to the scheduling queue.
361
399
This will trigger the Unreserve phase in [Reserve plugins](#reserve).
362
400
-->
363
- 1 . ** 拒绝** \
401
+ 2 . ** 拒绝** \
364
402
如果任何 Permit 插件拒绝 Pod,则该 Pod 将被返回到调度队列。
365
403
这将触发 [ Reserve 插件] ( #reserve ) 中的 Unreserve 阶段。
366
404
@@ -372,7 +410,7 @@ _Permit_ 插件在每个 Pod 调度周期的最后调用,用于防止或延迟
372
410
and the Pod is returned to the scheduling queue, triggering the
373
411
Unreserve phase in [Reserve plugins](#reserve).
374
412
-->
375
- 1 . ** 等待** (带有超时) \
413
+ 3 . ** 等待** (带有超时)\
376
414
如果一个 Permit 插件返回 “等待” 结果,则 Pod 将保持在一个内部的 “等待中”
377
415
的 Pod 列表,同时该 Pod 的绑定周期启动时即直接阻塞直到得到批准。
378
416
如果超时发生,** 等待** 变成 ** 拒绝** ,并且 Pod
@@ -384,7 +422,7 @@ While any plugin can access the list of "waiting" Pods and approve them
384
422
(see [`FrameworkHandle`](https://git.k8s.io/enhancements/keps/sig-scheduling/624-scheduling-framework#frameworkhandle)), we expect only the permit
385
423
plugins to approve binding of reserved Pods that are in "waiting" state. Once a Pod
386
424
is approved, it is sent to the [PreBind](#pre-bind) phase.
387
- -->
425
+ -->
388
426
尽管任何插件可以访问 “等待中” 状态的 Pod 列表并批准它们
389
427
(查看 [ ` FrameworkHandle ` ] ( https://git.k8s.io/enhancements/keps/sig-scheduling/624-scheduling-framework#frameworkhandle ) )。
390
428
我们期望只有允许插件可以批准处于 “等待中” 状态的预留 Pod 的绑定。
@@ -402,15 +440,14 @@ example, a pre-bind plugin may provision a network volume and mount it on the
402
440
target node before allowing the Pod to run there.
403
441
-->
404
442
这些插件用于执行 Pod 绑定前所需的所有工作。
405
- 例如,一个 PreBind 插件可能需要制备网络卷并且在允许 Pod 运行在该节点之前
406
- 将其挂载到目标节点上 。
443
+ 例如,一个 PreBind 插件可能需要制备网络卷并且在允许 Pod
444
+ 运行在该节点之前将其挂载到目标节点上 。
407
445
408
446
<!--
409
447
If any PreBind plugin returns an error, the Pod is [rejected](#reserve) and
410
448
returned to the scheduling queue.
411
449
-->
412
- 如果任何 PreBind 插件返回错误,则 Pod 将被 [ 拒绝] ( #reserve ) 并且
413
- 退回到调度队列中。
450
+ 如果任何 PreBind 插件返回错误,则 Pod 将被[ 拒绝] ( #reserve ) 并且退回到调度队列中。
414
451
415
452
<!--
416
453
### Bind
@@ -434,11 +471,11 @@ Bind 插件用于将 Pod 绑定到节点上。直到所有的 PreBind 插件都
434
471
### PostBind {#post-bind}
435
472
436
473
<!--
437
- This is an informational extension point . Post-bind plugins are called after a
474
+ This is an informational interface . Post-bind plugins are called after a
438
475
Pod is successfully bound. This is the end of a binding cycle, and can be used
439
476
to clean up associated resources.
440
477
-->
441
- 这是个信息性的扩展点 。
478
+ 这是个信息性的接口 。
442
479
PostBind 插件在 Pod 成功绑定后被调用。这是绑定周期的结尾,可用于清理相关的资源。
443
480
444
481
<!--
@@ -464,7 +501,7 @@ Plugins that use this extension point usually should also use
464
501
<!--
465
502
## Plugin API
466
503
-->
467
- ## 插件 API
504
+ ## 插件 API {#plugin-api}
468
505
469
506
<!--
470
507
There are two steps to the plugin API. First, plugins must register and get
@@ -495,24 +532,24 @@ type PreFilterPlugin interface {
495
532
<!--
496
533
## Plugin configuration
497
534
-->
498
- ## 插件配置
535
+ ## 插件配置 {#plugin-configuration}
499
536
500
537
<!--
501
538
You can enable or disable plugins in the scheduler configuration. If you are using
502
539
Kubernetes v1.18 or later, most scheduling
503
540
[plugins](/docs/reference/scheduling/config/#scheduling-plugins) are in use and
504
541
enabled by default.
505
- -->
542
+ -->
506
543
你可以在调度器配置中启用或禁用插件。
507
- 如果你在使用 Kubernetes v1.18 或更高版本,大部分调度
508
- [ 插件] ( /zh-cn/docs/reference/scheduling/config/#scheduling-plugins )
544
+ 如果你在使用 Kubernetes v1.18 或更高版本,
545
+ 大部分调度 [ 插件] ( /zh-cn/docs/reference/scheduling/config/#scheduling-plugins )
509
546
都在使用中且默认启用。
510
547
511
548
<!--
512
549
In addition to default plugins, you can also implement your own scheduling
513
550
plugins and get them configured along with default plugins. You can visit
514
551
[scheduler-plugins](https://github.com/kubernetes-sigs/scheduler-plugins) for more details.
515
- -->
552
+ -->
516
553
除了默认的插件,你还可以实现自己的调度插件并且将它们与默认插件一起配置。
517
554
你可以访问 [ scheduler-plugins] ( https://github.com/kubernetes-sigs/scheduler-plugins )
518
555
了解更多信息。
@@ -521,7 +558,7 @@ plugins and get them configured along with default plugins. You can visit
521
558
If you are using Kubernetes v1.18 or later, you can configure a set of plugins as
522
559
a scheduler profile and then define multiple profiles to fit various kinds of workload.
523
560
Learn more at [multiple profiles](/docs/reference/scheduling/config/#multiple-profiles).
524
- -->
525
- 如果你正在使用 Kubernetes v1.18 或更高版本,你可以将一组插件设置为
526
- 一个调度器配置文件, 然后定义不同的配置文件来满足各类工作负载。
561
+ -->
562
+ 如果你正在使用 Kubernetes v1.18 或更高版本,你可以将一组插件设置为一个调度器配置文件,
563
+ 然后定义不同的配置文件来满足各类工作负载。
527
564
了解更多关于[ 多配置文件] ( /zh-cn/docs/reference/scheduling/config/#multiple-profiles ) 。
0 commit comments