Scheduling-K8S
Table of Contents
1. Overview
- The scheduling component in Kubernetes is a core responsibility of the control plane.
- Assign pods to nodes ensuring optimal resource allocation and management.
2. Primary Functionalities
2.1. Resource Optimization
- Considers CPU, memory requests, and constraints.
2.2. Affinity/Anti-affinity Rules
- Enables pod co-location or separation.
- https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity
2.3. Taints and Tolerations
- Ensures nodes can repel certain pods unless explicitly tolerated.
- https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
- good usecases:
- tainted the nodes with GPUs and running GPU demanding pods on such nodes by adding tolerations
2.4. NodeSelector and NodeAffinity
- Limits nodes that can host particular pods.
2.5. Priorities and Preemption
- Ensures urgent pods get priority using preemption.
- https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority
2.6. Eviction
2.7. Scheduler Algorithms:
- Priority Functions: Rank nodes based on set criteria.
- Predicate Functions: Determines if a pod can run on a particular node.
2.8. Custom Schedulers:
- Allows for user-defined policies and scheduling strategies.
2.9. Pod Topology Spread Constraints
3. Kube-Scheduler
Two basic stages to allocating a pod to a node:
- Filtering : disqualify candidates
- Scoring : prioritize candidates
3.1. Scheduling Policies
- configure predicates(for filtering) and Priorities(for scoring)
3.2. Scheduling Profiles
- configure plugins that implement different scheduling stages:
- QueueSort
- Filter
- Score
- Bind
- Reserve
- Permit
4. Scheduling Framework
The allocation of a pod is split in two phases:
- Scheduling Cycle : Decides
- Binding Cycle : applies the decision
5. Resources
- https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
- https://kubernetes.io/docs/reference/scheduling/policies/
- https://kubernetes.io/docs/reference/scheduling/config/#profiles
- https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/
- https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
- https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority
- https://kubernetes.io/docs/concepts/scheduling-eviction/node-pressure-eviction/
- https://kubernetes.io/docs/concepts/scheduling-eviction/api-eviction/