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 →Mitigating Staleness in Kubernetes Controllers: What You Need to Know
Kubernetes v1.36 introduces key features to tackle staleness in controllers, directly impacting your cluster's reliability. By leveraging atomic FIFO processing and the new ConsistencyStore, controllers can ensure they act on the most current data. This is a game-changer for production environments where stale data can lead to cascading failures.
Mastering Kubernetes Probes: Liveness, Readiness, and Startup Explained
Kubernetes probes are essential for maintaining application health in production. Liveness probes can automatically restart your containers when they enter a broken state, while readiness probes ensure traffic is only sent to healthy containers. Understanding these mechanisms is crucial for robust deployments.
Mastering Kubernetes CronJobs: Scheduling One-Time Jobs with Precision
Kubernetes CronJobs are essential for automating one-time jobs on a repeating schedule. With the right configuration, you can ensure your tasks run smoothly and on time. Learn how to leverage the .spec.schedule and .spec.jobTemplate fields effectively.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.