Kubernetes Pod Scheduling Inputs
Kubernetes Pod Scheduling Inputs determine where and how pods are placed, influencing cluster resource allocation and application deployment efficiency.
Kubernetes Pod Scheduling Inputs are the set of specifications, constraints, and cluster-state signals that the Kubernetes scheduler consumes when deciding which node should host a given Pod. These inputs originate from the PodSpec itself, from labels and taints attached to nodes, from the current resource utilization of the cluster, and from policy objects that govern how workloads may be placed relative to one another. The scheduler evaluates these inputs in two phases, filtering (predicates) and scoring (priorities), to arrive at a binding decision that assigns a Pod to a specific node.
Resource Requests and Limits
CPU and Memory Requests
Every container in a Pod may declare resources.requests for CPU and memory. The scheduler sums these values across all containers in a Pod and treats the total as the minimum capacity a candidate node must have available. Nodes whose allocatable capacity minus already-committed requests falls short of this sum are filtered out during the predicate phase.
Limits and Quality of Service
While resources.limits do not directly gate scheduling decisions, they influence the Pod's Quality of Service (QoS) class, which indirectly affects eviction behavior after placement. The three QoS classes are:
- Guaranteed: requests equal limits for every resource, on every container.
- Burstable: at least one request is set, but requests and limits are not equal.
- BestEffort: no requests or limits are specified at all.
apiVersion: v1
kind: Pod
metadata:
name: scheduling-inputs-example
spec:
containers:
- name: app
image: registry.example.com/app:1.4.0
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
Node Selection Mechanisms
nodeSelector
nodeSelector is the simplest scheduling input, requiring an exact match between key-value pairs declared on the Pod and labels present on the node.
spec:
nodeSelector:
disktype: ssd
Node Affinity and Anti-Affinity
Node affinity extends nodeSelector with expressive matching operators (In, NotIn, Exists, DoesNotExist, Gt, Lt) and two enforcement strengths:
requiredDuringSchedulingIgnoredDuringExecution: a hard constraint; nodes not matching are excluded.preferredDuringSchedulingIgnoredDuringExecution: a soft constraint; matching nodes receive a scoring bonus but non-matching nodes remain eligible.
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- amd64
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 20
preference:
matchExpressions:
- key: zone
operator: In
values:
- us-east-1a
Pod Affinity and Anti-Affinity
Pod affinity inputs consider the labels of Pods already running on candidate nodes, rather than node labels themselves. This allows co-location (affinity) or spreading (anti-affinity) of related workloads, scoped by a topologyKey such as kubernetes.io/hostname or topology.kubernetes.io/zone.
Taints and Tolerations
Node Taints
A taint applied to a node repels Pods unless those Pods carry a matching toleration. Taints are expressed as key=value:effect, where effect is one of NoSchedule, PreferNoSchedule, or NoExecute.
Pod Tolerations
spec:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "gpu-workloads"
effect: "NoSchedule"
Tolerations do not force placement onto a tainted node; they only permit it. Actual placement still depends on other scheduling inputs such as affinity or resource fit.
Topology Spread Constraints
topologySpreadConstraints instruct the scheduler to distribute Pods evenly across a defined topology domain, such as zones or hostnames, bounded by a maxSkew value that caps the allowable imbalance.
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: scheduling-inputs-example
Cluster State Signals
Node Conditions
The scheduler excludes nodes reporting Ready=False, as well as nodes under MemoryPressure, DiskPressure, or PIDPressure conditions, since these signals indicate the node cannot safely accept additional workloads.
Volume Topology
For Pods referencing PersistentVolumeClaims bound to zonal or node-local storage, the scheduler restricts candidate nodes to those within the same topology domain as the underlying volume.
Pod Priority and Preemption
priorityClassName assigns a numeric priority to a Pod. When no node satisfies a high-priority Pod's requirements, the scheduler may evaluate preemption, evicting lower-priority Pods on a candidate node to free the capacity needed for scheduling.
Scheduling Decision Flow
The filter phase discards nodes that violate any hard constraint among the inputs above. The score phase ranks the remaining nodes using soft preferences, resource balance heuristics, and affinity weights, and the scheduler binds the Pod to the highest-scoring node.