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 docsUnified observability — logs, uptime monitoring, and on-call in one place. Used by 50,000+ engineering teams to ship faster and sleep better.
Try Better Stack free →Mastering WG Device Management in Kubernetes
Device management in Kubernetes just got a major upgrade with Dynamic Resource Allocation (DRA). This framework replaces the rigid device plugin model, allowing for a flexible, declarative API that enhances how you manage hardware resources. Dive in to understand how the ResourceSlice and ResourceClaim APIs work together to optimize your workloads.
Mastering Workload-Aware Scheduling in Kubernetes v1.36
Kubernetes v1.36 introduces powerful workload-aware scheduling features that can transform how you deploy applications. With the new Workload and PodGroup APIs, you can prevent resource wastage and deadlocks through gang scheduling. This is a game changer for managing complex workloads effectively.
Unlocking Kubernetes v1.36: PSI Metrics for Proactive Resource Management
Kubernetes v1.36 introduces Pressure Stall Information (PSI) metrics, a game changer for monitoring resource saturation. With cumulative totals and moving averages, you can now detect issues before they escalate into outages.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.