What is Scheduling?
The Kubernetes scheduler is responsible for placing Pods onto Nodes in the cluster. It continuously monitors the state of the cluster, including the availability of resources, node capacity, and any constraints imposed by users.
Why is Scheduling Important?
Scheduling is important because it ensures that Pods are placed onto suitable Nodes, taking into account factors such as:
Resource availability: The scheduler ensures that Pods have enough CPU, memory, and other resources to run successfully.
Node affinity/anti-affinity: Users can specify preferences for where Pods should be placed, and the scheduler will try to fulfill these preferences.
Node capacity: The scheduler ensures that the cluster doesn’t become overloaded by distributing Pods evenly across available Nodes.
https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
Scheduling Process
The Kubernetes scheduler uses a series of plugins to evaluate Pods and Nodes. The scheduler selects the most suitable Node for each Pod based on a variety of factors, such as:
Pod requests and limits: The scheduler considers the amount of CPU, memory, and other resources requested by the Pod, as well as any limits imposed on these resources.
Node resources: The scheduler checks if the Node has sufficient resources to accommodate the Pod’s requests and limits.
Node affinity/anti-affinity: The scheduler considers any preferences for where Pods should be placed, as specified in the Pod’s definition.
Node capacity: The scheduler tries to distribute Pods evenly across available Nodes to avoid overloading any single Node.
https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
Scheduling Plugins
The Kubernetes scheduler uses a series of plugins to perform its tasks. The plugins are responsible for:
Filtering: The filtering plugins determine whether a Node is even considered for scheduling.
Prioritization: The prioritization plugins evaluate the suitability of each Node and assign it a priority score.
Binding: The binding plugin selects the Node with the highest priority and binds the Pod to that Node.
https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
Scheduling Policies
The scheduler uses a scheduling policy to determine how to prioritize Nodes for Pod placement. The scheduling policy is defined in the scheduler.alpha.kubernetes.io/priority
annotation on the Pod. The scheduler uses this annotation to select the appropriate plugin chain for scheduling the Pod.
Top-Level Directory Explanations
build - This directory contains the build scripts and configurations for Kubernetes components. It includes subdirectories like build-image
, lib
, pause
, and server-image
that build different parts of Kubernetes, such as images, libraries, and server components.
hack - This directory contains development scripts and tools for the Kubernetes project. It includes subdirectories like boilerplate
, conformance
, e2e-internal
, gen-swagger-doc
, jenkins
, lib
, make-rules
, testdata
, and tools
.
pkg - This directory contains the Go packages for Kubernetes components. It includes subdirectories like api
, apis
, auth
, capabilities
, client
, cluster
, controller
, controlplane
, credentialprovider
, features
, fieldpath
, generated
, kubeapiserver
, kubectl
, kubemark
, printers
, probe
, proxy
, quota
, registry
, routes
, scheduler
, security
, serviceaccount
, util
, volume
, and windows
. These packages define and implement various Kubernetes features and components.
test - This directory contains the test scripts and configurations for Kubernetes components. It includes subdirectories like cmd
, conformance
, e2e
, fixtures
, fuzz
, images
, kubemark
, e2e_kubeadm
, e2e_node
, and utils
.