<p>I'm learning the <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/" rel="nofollow noreferrer">k8s Scheduling Framework</a>, scheduling cycle phase.
I can't catch an actual difference between filters &quot;PreFilter&quot;, &quot;Filter&quot; and &quot;PostFilter&quot;.
What is the real difference between them, what is the real work on a simple example?</p>
<ol>
<li>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?</li>
<li>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?</li>
<li>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?</li>
</ol>
<p><a href="https://i.stack.imgur.com/QbfZE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QbfZE.jpg" alt="enter image description here" /></a></p>

Kirill K
<p>kube-scheduler selects a node for the pod in a 2-step operation:</p>
<ul>
<li><p>Filtering</p>
</li>
<li><p>Scoring</p>
</li>
</ul>
<p>You can understand from the doc <a href="https://www.kubesphere.io/blogs/understand-requests-and-limits-in-kubernetes/" rel="nofollow noreferrer">Kubernetes scheduler</a> 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.</p>
<p>The schedule pipeline is divided into the schedule thread, wait thread, and bind thread.</p>
<ul>
<li>The schedule thread is divided into the pre-filter, filter, post-filter, score, and reserve phases.</li>
</ul>
<p>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.</p>
<p>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.</p>
<ul>
<li><p><strong>PreFilter</strong> preprocesses pod-related requests, such as pod cache requests.</p>
</li>
<li><p><strong>Filter</strong> allows you to add custom filters. For example, GPU share is implemented by a custom filter.</p>
</li>
<li><p><strong>PostFilter</strong> is used to process logs and metrics or preprocess data before the score phase. You can configure cache plugins through PostFilter.</p>
</li>
</ul>
<p>The components that implement the extension points of kubernetes scheduler are called <strong>Plugins.</strong></p>
<p>You can refer to the doc <a href="https://www.alibabacloud.com/blog/getting-started-with-kubernetes-%7C-scheduling-process-and-scheduler-algorithms_596299" rel="nofollow noreferrer">filters</a> authored by Wang Menghai for more information.</p>
