✦ For everyone, free.

Practical knowledge for real and everyday life

Home

16 Kubernetes Resource Management

Kubernetes Resource Management ensures efficient use of cluster resources through scheduling, allocation, and monitoring across containerized workloads.

Kubernetes Resource Management is the set of mechanisms Kubernetes provides for declaring, allocating, limiting, and governing the CPU, memory, and other compute resources consumed by containers, ensuring workloads receive the capacity they need while preventing any single workload from starving others sharing the same node.


Requests and Limits

Resource Requests

A resource request specifies the minimum amount of a resource, such as CPU or memory, that a container is expected to need. The scheduler uses requests to decide which nodes have enough available capacity to accommodate a Pod, treating the request as a reservation against the node's allocatable capacity.

Resource Limits

A resource limit specifies the maximum amount of a resource a container is allowed to consume. Exceeding a CPU limit results in the container being throttled, while exceeding a memory limit results in the container being terminated, since memory cannot be reclaimed from a process without stopping it.

request actual usage limit

Quality of Service Classes

Guaranteed

A Pod is classified as Guaranteed when every container specifies equal requests and limits for both CPU and memory, giving it the strongest protection against eviction under node resource pressure.

Burstable

A Pod is classified as Burstable when it specifies requests that are lower than its limits, or specifies requests without matching limits, allowing it to use additional resources when available while still receiving some priority protection over Pods with no requests at all.

BestEffort

A Pod with no resource requests or limits specified at all is classified as BestEffort, receiving the lowest scheduling priority for resource contention and the first consideration for eviction when a node experiences resource pressure.


Namespace-Level Resource Governance

ResourceQuotas

A ResourceQuota restricts the aggregate amount of resources that can be consumed within a namespace, such as total CPU, memory, or object counts, preventing a single namespace from consuming disproportionate cluster capacity.

LimitRanges

A LimitRange sets default, minimum, and maximum resource constraints for individual containers or Pods within a namespace, ensuring that workloads which do not specify their own requests and limits still receive sensible defaults.


Node-Level Resource Enforcement

Allocatable Capacity

Each node reports an allocatable capacity, which is its total physical capacity minus resources reserved for the operating system and Kubernetes system components such as the kubelet, ensuring workload Pods do not starve the node's own critical processes.

Eviction Under Pressure

When a node experiences resource pressure, such as running low on memory, the kubelet evicts Pods to reclaim resources, prioritizing eviction based on Quality of Service class and how far a Pod's actual usage exceeds its requests.


Autoscaling and Resource Management

Horizontal Scaling

The Horizontal Pod Autoscaler adjusts the number of Pod replicas based on observed resource utilization relative to requests, using requests as the baseline against which utilization percentages are calculated.

Vertical Scaling

The Vertical Pod Autoscaler instead recommends or automatically adjusts the requests and limits of individual Pods based on their observed historical usage, reducing the need for manual tuning of resource specifications over time.


Resource Allocation Diagram

Node Capacity system reserved Pod requests unallocated capacity

Together, requests, limits, quality of service classes, and namespace-level quotas form a layered system that balances scheduling accuracy, fairness between workloads, and protection of node stability under contention.