Mastering Memory QoS in Kubernetes v1.36: Tiered Memory Protection Explained
Memory QoS exists to address the challenges of memory management in Kubernetes. As applications scale, ensuring that critical workloads have guaranteed memory while allowing for flexibility in less critical ones becomes essential. Memory QoS achieves this by using the cgroup v2 memory controller, allowing you to specify hard and soft memory protections for your pods.
At its core, Memory QoS utilizes four key interfaces: memory.max for hard limits, memory.min for guaranteed protection (only for Guaranteed Pods), memory.low for soft protection (for Burstable Pods), and memory.high for throttling. The kubelet plays a crucial role by maintaining memory.min across the kubepods root cgroup and memory.low for Burstable QoS cgroups. You can configure Memory QoS through the kubelet configuration, enabling it with featureGates.MemoryQoS and specifying the memoryReservationPolicy to control how memory is reserved.
In production, understanding how to set these parameters effectively is key. Ensure your Kubernetes version is v1.36 or later, and ideally, use a kernel version of 5.9 or higher to avoid known issues like the kernel livelock. The Memory QoS feature is still in alpha, so be prepared for potential changes and ensure thorough testing before rolling it out to critical environments.
Key takeaways
- →Enable Memory QoS by setting featureGates.MemoryQoS to true in your kubelet configuration.
- →Use memory.min for Guaranteed Pods to ensure hard memory protection.
- →Implement memory.low for Burstable Pods to provide soft memory protection.
- →Monitor memory metrics using the command: curl -sk https://localhost:10250/metrics | grep memory_qos.
- →Be aware of kernel compatibility; use kernel 5.9 or higher to avoid livelock issues.
Why it matters
In production, Memory QoS can significantly improve resource allocation, ensuring critical applications remain responsive while optimizing overall cluster performance. This leads to better resource utilization and cost efficiency.
Code examples
1apiVersion: kubelet.config.k8s.io/v1beta1
2kind: KubeletConfiguration
3featureGates:
4 MemoryQoS: true
5memoryReservationPolicy: TieredReservation # Options: None (default), TieredReservation
6memoryThrottlingFactor: 0.9 # Optional: default is 0.91apiVersion: kubelet.config.k8s.io/v1beta1
2kind: KubeletConfiguration
3featureGates:
4 MemoryQoS: true
5memoryReservationPolicy: None
6# This is the default$ curl -sk https://localhost:10250/metrics | grep memory_qosWhen 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 docs35% off certifications and e-learning with code SEPT26BTS35, or 40% off bundles and instructor-led training with SEPT26BTS40. New this month: the MCPA (Model Context Protocol Associate) certification.
Unlocking Performance: Kubernetes Pod-Level Resource Managers in Beta
Kubernetes v1.37 brings Pod-Level Resource Managers to Beta, addressing the need for exclusive resource allocation for latency-sensitive applications. This feature allows Kubelet to make smarter hardware placement decisions using pod-level resource declarations.
Memory QoS in Kubernetes v1.37: A Game Changer for Resource Management
Kubernetes v1.37 introduces Memory QoS, a feature that enhances memory management for containers. By using the memory controller, it provides better guidance on how to treat container memory, particularly for Burstable and BestEffort containers.
Mastering Kubernetes v1.37: Scheduler Preemption for In-Place Pod Resize
Kubernetes v1.37 introduces a game-changing feature: scheduler preemption for in-place pod resizing. This allows the scheduler to free up node capacity by evicting lower-priority pods, ensuring critical workloads can scale effectively. Dive in to understand how this works and what you need to watch out for in production.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.