英文:
What is the difference: PreFilter vs Filter vs PostFilter in the concepts of Scheduling framework?
问题
我正在学习k8s调度框架,调度周期阶段。
我无法区分过滤器"PreFilter"、"Filter"和"PostFilter"之间的实际区别。
它们之间的真正区别是什么,在一个简单的示例上的真正工作是什么?
- PreFilter - 这些插件用于预处理有关Pod的信息...例如:如果Pod的内存请求过大(超过集群中节点的最大值),则此插件将返回错误并中止调度周期。是这样吗?
- Filter - 调度器的主要工作。这些插件用于过滤不满足Pod调度约束的节点。
因此,这个插件是用于与节点过滤一起工作的,对吗?
例如:如果Pod具有某些nodeSelector,则此插件将过滤掉不满足nodeSelector的所有节点。对吗? - PostFilter - 这些插件在过滤阶段之后调用,但仅当找不到适合Pod的节点时。
例如:如果我们有一个具有某些nodeSelector的Pod,但是节点上没有足够的某些资源(例如内存),那么...我们将在此调度周期上运行下一个插件(评分...)。
我有点困惑,这个插件的真正作用是什么?
英文:
I'm learning the k8s Scheduling Framework, scheduling cycle phase.
I can't catch an actual difference between filters "PreFilter", "Filter" and "PostFilter".
What is the real difference between them, what is the real work on a simple example?
- PreFilter -These plugins are used to pre-process info about the
Pod... ex: If the POD has too big memory request (more than the max
of the nodes in our cluster) then this plugin returns an error
and, the scheduling cycle is aborted. Is it right? - Filter - the main work of the scheduler. These plugins are used to filter out nodes that don't satisfy the Pod's scheduling constraints.
So, this plugin about to work with node filter, is it right?
ex: If the POD has some nodeSelector, then this plugin will filter out all nodes that don't satisfy the nodeSelector. Is it right? - PostFilter - These plugins are called after filter phase, but only when no feasible nodes were found for the pod.
ex: If we have some POD with some nodeSelector, but there is not enough some resources (ex. memory) on that nodes, then .... we run next plugins on this scheduling cycle (score...).
I'm little confused, what is the real job of this plugin?
答案1
得分: 1
kube-scheduler 会在两个步骤中为 Pod 选择一个节点:
-
过滤(Filtering)
-
评分(Scoring)
你可以从由 Yunkun 编写的 Kubernetes 调度器文档 中了解到,调度器通过一个 informer 将待调度的 Pod 插入到队列中。这些 Pod 会周期性地从队列中弹出,并被推送到调度流水线中。
调度流水线分为调度线程、等待线程和绑定线程。
- 调度线程分为前过滤、过滤、后过滤、评分和保留阶段。
过滤阶段选择与 Pod 规范相一致的节点。评分阶段对所选节点进行评分和排序。保留阶段将一个 Pod 放入最佳排序节点的节点缓存中,表示该 Pod 分配给了该节点。这样,在节点被筛选和评分时,等待调度的下一个 Pod 就知道了先前分配给节点的 Pod。
只有在调度线程中一个接一个地调度 Pod,而在等待线程和绑定线程中以异步和并行的方式调度。
- 前过滤 预处理与 Pod 相关的请求,比如 Pod 缓存请求。
- 过滤 允许你添加自定义过滤器。例如,GPU 分享是通过自定义过滤器实现的。
- 后过滤 用于处理日志和指标或在评分阶段之前预处理数据。你可以通过后过滤配置缓存插件。
实现 Kubernetes 调度器扩展点的组件称为插件(Plugins)。
你可以参考由王梦海编写的 filters 文档 以获取更多信息。
英文:
kube-scheduler selects a node for the pod in a 2-step operation:
-
Filtering
-
Scoring
You can understand from the doc Kubernetes scheduler written by Yunkun, that the scheduler inserts the pods to be scheduled into a queue through an informer. These pods are cyclically popped out from the queue and pushed into a schedule pipeline.
The schedule pipeline is divided into the schedule thread, wait thread, and bind thread.
- The schedule thread is divided into the pre-filter, filter, post-filter, score, and reserve phases.
The filter phase selects the nodes consistent with pod spec. The score phase scores and sorts the selected nodes. The reserve phase puts a pod in the node cache of the optimal sorted node, indicating that the pod is assigned to this node. In this way, the next pod that waits for scheduling knows the previously assigned pod when the node is filtered and scored.
Pods are scheduled one by one only in the schedule thread and are scheduled in the wait thread and bind thread in an asynchronous and parallel manner.
-
PreFilter preprocesses pod-related requests, such as pod cache requests.
-
Filter allows you to add custom filters. For example, GPU share is implemented by a custom filter.
-
PostFilter is used to process logs and metrics or preprocess data before the score phase. You can configure cache plugins through PostFilter.
The components that implement the extension points of kubernetes scheduler are called Plugins.
You can refer to the doc filters authored by Wang Menghai for more information.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论