tezvyn:

Kubernetes Scheduler Framework: A Plugin System for Pod Placement

AI-drafted, machine-checkedSource: kubernetes.ioadvanced
Kubernetes Scheduler Framework: A Plugin System for Pod Placement

The Kubernetes Scheduler Framework is a plugin pipeline for pod placement. Use it to add custom logic—like co-scheduling ML jobs or avoiding specific nodes—without forking Kubernetes. The footgun: a slow plugin can bottleneck your entire cluster's scheduling.

WHY IT EXISTS: The default Kubernetes scheduler is a generalist, designed for a wide range of workloads. For specialized tasks like high-performance computing or large-scale batch jobs, you often need more control over pod placement. The Scheduler Framework was created to allow custom scheduling logic without having to fork and maintain a custom version of the entire Kubernetes scheduler component.

THE MENTAL MODEL: Think of the Scheduler Framework as a plugin pipeline for the kube-scheduler. When a new Pod needs a home, it passes through a series of extension points, or hooks. You can write custom plugins that attach to these hooks to influence the decision, much like adding middleware to a web server's request-response cycle.

HOW IT WORKS: The framework defines a series of extension points in the scheduling cycle. For each Pod, the scheduler first runs "Filter" plugins to eliminate nodes that cannot run the Pod (e.g., insufficient resources). Then, it runs "Score" plugins to rank the remaining viable nodes, and the node with the highest score wins. Other key extension points include "QueueSort" to prioritize pods waiting for scheduling, "Permit" to approve or delay a binding (useful for gang scheduling), and "Bind" to execute the final placement. You can enable or disable plugins, including the default ones, in a scheduler profile.

WHEN TO USE IT: Use the framework when the default scheduling features like node affinity, taints, and tolerations are not enough. It's powerful for implementing custom resource management, enforcing complex business rules (e.g., license-based node restrictions), or enabling advanced scheduling patterns like gang scheduling (all-or-nothing for a group of pods) and resource bin-packing.

WHEN NOT TO USE IT: Avoid it for standard use cases. The default scheduler is highly optimized and sufficient for most applications. Adding custom plugins introduces complexity in configuration, testing, and cluster upgrades. If you can achieve your goal with standard Pod Topology Spread Constraints or Node Affinity, use those first.

ONE CANONICAL EXAMPLE: A common use case is creating a custom "Score" plugin to influence bin-packing. A default scheduler might spread pods out to be safe. A custom plugin could score nodes higher if they already have pods from the same service, concentrating workloads to free up other nodes for larger jobs or to scale them down, saving costs. This is a trade-off you can implement via a simple plugin.

Read the original → kubernetes.io

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.