Mastering Kubernetes v1.37: Scheduler Preemption for In-Place Pod Resize
In Kubernetes, managing resources efficiently is crucial, especially as workloads scale. The new scheduler preemption for in-place pod resize feature addresses a common pain point: when nodes are fully utilized, critical pods may not be able to resize due to lack of available resources. By allowing the scheduler to preempt lower-priority workloads, Kubernetes ensures that essential applications can adapt dynamically to changing demands.
This feature integrates directly into the kube-scheduler's core scheduling cycle. When a pod requests an in-place resize and is marked with a Deferred status, the kube-scheduler actively monitors these pods. It identifies lower-priority 'victim' pods on the same node and initiates their graceful eviction, effectively freeing up the necessary capacity. To enable this feature, you must set the InPlacePodVerticalScalingSchedulerPreemption feature gate to true in your cluster configuration. Additionally, you can control preemption behavior on specific nodes using the spec.podPreemptionPolicy field.
In production, ensure your cluster is running Kubernetes v1.37 or later, and that all control plane components have the feature gate enabled. Be cautious with the node images you use; they must correspond to Kubernetes v1.37 or later. This feature is still in alpha, so expect potential instability and be prepared for edge cases where preemption may not behave as expected.
Key takeaways
- →Enable the InPlacePodVerticalScalingSchedulerPreemption feature gate to allow preemption for critical workloads.
- →Monitor pods with a Deferred resize status to manage resource allocation effectively.
- →Use the spec.podPreemptionPolicy to customize preemption behavior on specific nodes.
Why it matters
This feature significantly enhances resource management, allowing critical applications to scale even under heavy load. It helps prevent downtime and improves overall application reliability in production environments.
Code examples
# kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
featureGates:
InPlacePodVerticalScalingSchedulerPreemption: truekind create cluster --config kind-config.yaml --image kindest/node:v1.37.0kubectl get nodes -o custom-columns=NAME:.metadata.name,ALLOCATABLE_CPU:.status.allocatable.cpuWhen NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsIndustry-standard certifications built by the people behind Linux and Kubernetes. Earn the CKA — the gold standard Kubernetes administrator cert. OpsCanary readers get 30% off year-round with code OPSCANARY3.
Get CKA certified →Tracing Kueue Admission: Unraveling Workload Mysteries with Headlamp
Understanding how Kueue admission works is crucial for optimizing resource allocation in Kubernetes. With the Kueue plugin for Headlamp, you can trace the admission path of a Workload, revealing insights into its resource requests and conditions. Dive in to learn how to leverage this tool effectively.
Navigating the Shift to cgroup v2 in Kubernetes
Kubernetes is evolving, and so is its resource management with the shift to cgroup v2. Understanding how cgroups manage resources is crucial, especially with features like Memory QoS and the new kubelet defaults. This article dives into what you need to know to leverage these changes effectively.
Mastering Node Swap in Kubernetes: Boosting Workload Resilience
Node swap can be a game changer for your Kubernetes workloads, especially during traffic spikes. By enabling the Linux kernel to page out memory to disk, you can effectively manage memory oversubscription and improve application performance.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.