⎈ k8s knowledge compiler

Scheduling Framework [page]deterministic

concepts

The _scheduling framework_ is a pluggable architecture for the Kubernetes scheduler. It consists of a set of "plugin" APIs that are compiled directly into the scheduler. These APIs allow most scheduling features to be implemented as plugins, while keeping the scheduling "core" lightweight and maintainable. Refer to the [design proposal of the scheduling framework][kep] for more technical information on the design of the framework.

[kep]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/624-scheduling-framework/README.md

## Framework workflow

The Scheduling Framework defines a few extension points. Scheduler plugins register to be invoked at one or more extension points. Some of these plugins can change the scheduling decisions and some are informational only.

Each attempt to schedule one Pod is split into two phases, the scheduling cycle and the binding cycle.

### Scheduling cycle & binding cycle

The scheduling cycle selects a node for the Pod, and the binding cycle applies that decision to the cluster. Together, a scheduling cycle and binding cycle are referred to as a "scheduling context".

Scheduling cycles are run serially, while binding cycles may run concurrently.

A scheduling or binding cycle can be aborted if the Pod is determined to be unschedulable or if there is an internal error. The Pod will be returned to the queue and retried.

## Interfaces

The following picture shows the scheduling context of a Pod and the interfaces that the scheduling framework exposes.

One plugin may implement multiple interfaces to perform more complex or stateful tasks.

Some interfaces match the scheduler extension points which can be configured through [Scheduler Configuration](/docs/reference/scheduling/config/#extension-points).

![](/images/docs/scheduling-framework-extensions.png)

### PreEnqueue {#pre-enqueue}

These plugins are called prior to adding Pods to the internal active queue, where Pods are marked as ready for scheduling.

Only when all PreEnqueue plugins return `Success`, the Pod is allowed to enter the active queue. Otherwise, it's placed in the internal unschedulable Pods list, and doesn't get an `Unschedulable` condition.

For more details about how internal scheduler queues work, read [Scheduling queue in kube-scheduler](https://github.com/kubernetes/community/blob/f03b6d5692bd979f07dd472e7b6836b2dad0fd9b/contributors/devel/sig-scheduling/scheduler_queues.md).

### EnqueueExtension

EnqueueExtension is the interface where the plugin can control whether to retry scheduling of Pods rejected by this plugin, based on changes in the cluster. Plugins that implement PreEnqueue, PreFilter, Filter, Reserve or Permit should implement this interface.

### QueueingHint

QueueingHint is a callback function for deciding whether a Pod can be requeued to the active queue or backoff queue. It's executed every time a certain kind of event or change happens in the cluster. When the QueueingHint finds that the event might make the Pod schedulable, the Pod is put into the active queue or the backoff queue so that the scheduler will retry the scheduling of the Pod.

### QueueSort {#queue-sort}

These plugins are used to sort Pods in the scheduling queue. A queue sort plugin essentially provides a `Less(Pod1, Pod2)` function. Only one queue sort plugin may be enabled at a time.

### PreFilter {#pre-filter}

These plugins are used to pre-process info about the Pod, or to check certain conditions that the cluster or the Pod must meet. If a PreFilter plugin returns an error, the scheduling cycle is aborted.

### Filter

These plugins are used to filter out nodes that cannot run the Pod. For each node, the scheduler will call filter plugins in their configured order. If any filter plugin marks the node as infeasible, the remaining plugins will not be called for that node. Nodes may be evaluated concurrently.

### PostFilter {#post-filter}

These plugins are called after the Filter phase, but …(trimmed)

Sources

concepts/scheduling-eviction/scheduling-framework.md · docScheduling Framework

Related (21)

part_of Framework workflowdescribes conf=1
part_of Interfacesdescribes conf=1
part_of Plugin APIdescribes conf=1
part_of Plugin configurationdescribes conf=1
part_of Scheduling cycle & binding cycledescribes conf=1
part_of PreEnqueue {#pre-enqueue}describes conf=1
part_of EnqueueExtensiondescribes conf=1
part_of QueueingHintdescribes conf=1
part_of QueueSort {#queue-sort}describes conf=1
part_of PreFilter {#pre-filter}describes conf=1
part_of Filterdescribes conf=1
part_of PostFilter {#post-filter}describes conf=1
part_of PreScore {#pre-score}describes conf=1
part_of Score {#scoring}describes conf=1
part_of NormalizeScore {#normalize-scoring}describes conf=1
part_of Reserve {#reserve}describes conf=1
part_of Permitdescribes conf=1
part_of PreBind {#pre-bind}describes conf=1
part_of Binddescribes conf=1
part_of PostBind {#post-bind}describes conf=1
api_for Schedulingdocuments API object conf=1

← all Docs