Kubernetes v1.36 Enhances Resource Management with Pod-Level Control

| 5 min read
Kubernetes v1.36 has rolled out a noteworthy enhancement: the introduction of Pod-Level Resource Managers as an alpha feature. This is more significant than it appears at first glance, as it fundamentally shifts the resource management paradigm, particularly for workloads where performance is critical. Prior to this, the kubelet's approach to resource allocation was container-centric. Now, with pod-level resource specifications (.spec.resources), Kubernetes allows for a more nuanced strategy, broadening its capabilities to factor in entire pod configurations rather than just individual containers.

The Importance of Pod-Level Resource Managers

Why does this change matter? For high-stakes applications like machine learning training or low-latency databases, predictable performance is key. These workloads often require tightly controlled, non-uniform memory access (NUMA) resources that are dedicated to primary application containers. Traditionally, when running pods that consist of multiple containers—often including sidecars for tasks like logging or service mesh—achieving this balance was a challenge. Pre-1.36, allocating exclusive resources to main application containers often meant that every container within the pod had to receive similar treatment. This led to inefficiencies, especially for lightweight sidecar containers, which didn't necessitate the same resource allocation but still had to be included for the pod’s resource request quota. If administrators chose not to allocate these resources, they faced losing the Guaranteed Quality of Service (QoS) from the pod, effectively compromising performance gains.

What Pod-Level Resource Managers Bring

With the introduction of pod-level resource managers, Kubernetes allows for "hybrid resource allocation models." By setting the kubelet to support pod-level resource management through the PodLevelResourceManagers and PodLevelResources feature gates, you can create sophisticated resource strategies that maintain NUMA alignment while optimizing resource usage.

Practical Applications

Let’s break this down with real-world scenarios. Taking a latency-sensitive database pod as an example, imagine it houses not just the main database container but also sidecars like a local metrics exporter and a backup agent. When configured with the pod topology manager scope, you’re able to achieve NUMA alignment for the entire pod. This means the primary database container secures its exclusive CPU and memory from its designated NUMA node, while auxiliary containers can operate within a shared resource pool, insulated from the core database's allocated resources. This arrangement prevents the spillage of dedicated resources on lighter containers while still co-locating them efficiently without performance penalties.
apiVersion: v1
kind: Pod
metadata:
  name: tightly-coupled-database
spec:
  resources:
    requests:
      cpu: "6"
      memory: "12Gi"
    limits:
      cpu: "6"
      memory: "12Gi"
  initContainers:
  - name: metrics-exporter
    image: metrics-exporter:v1
  - name: backup-agent
    image: backup-agent:v1
  containers:
  - name: database
    image: database:v1
    resources:
      requests:
        cpu: "6"
        memory: "12Gi"
      limits:
        cpu: "6"
        memory: "12Gi"
Next, consider a pod running a GPU-intensive machine learning workload alongside a generic service mesh sidecar. Under the container topology manager scope, the kubelet evaluates the requirements of each container distinctly, letting you dedicate NUMA-aligned resources exclusively to the ML container while allowing the sidecar to operate in the node-wide shared pool. This ensures that expensive resources are allocated where they matter most.
apiVersion: v1
kind: Pod
metadata:
  name: ml-workload
spec:
  resources:
    requests:
      cpu: "4"
      memory: "8Gi"
    limits:
      cpu: "4"
      memory: "8Gi"
  initContainers:
  - name: service-mesh-sidecar
    image: service-mesh:v1
  containers:
  - name: ml-training
    image: ml-training:v1
    resources:
      requests:
        cpu: "3"
        memory: "6Gi"
      limits:
        cpu: "3"
        memory: "6Gi"

CPU Management and Isolation

With these mixed workloads, the mechanisms of isolation vary. Exclusive containers get their CPU CFS quota enforcement disabled, enabling uninterrupted performance. In contrast, containers that are part of the shared pool will have their CPU CFS quotas enforced at the pod level, which secures their usage within the defined overall budget while still ensuring fairness.

Enabling Pod-Level Resource Managers

To activate this feature, Kubernetes administrators should ensure that their systems are running version 1.36 or a later release. The setup involves configuring certain feature gates and topology manager policies. Notably, enable the PodLevelResources and PodLevelResourceManagers gates, adjust the Topology Manager to a policy other than none, and specify whether the scope is set to pod or container. Consult the official documentation for precise details on configurations and related links to enable the feature effectively.

Monitoring for Changes

As this feature is still in alpha, Kubernetes has introduced several new metrics to empower administrators in monitoring resource allocations. Metrics like resource_manager_allocations_total will provide insights into both successful and failed allocations, further aiding in the understanding of how resources are distributed within the pods. Finally, keep in mind the potential limitations of this alpha feature, such as compatibility and requirements, so it’s wise to review the documentation on limitations for more detailed guidance. Each step in utilizing pod-level resource managers represents an exciting stride towards enhanced performance, particularly as your feedback will be invaluable in refining this alpha feature. If you encounter issues or have experiences to share, don’t hesitate to reach out through official Kubernetes channels, such as the Slack community or the mailing list.