Kubernetes LimitRange: Setting Guardrails for Pod Resources

LimitRange acts like a bouncer for Pod resources, setting min/max CPU and memory rules for each Pod in a namespace. It's used to prevent resource hogging and apply sensible defaults.
WHY IT EXISTS: To prevent two common problems in a Kubernetes cluster: first, Pods created without resource requests/limits, which get the lowest quality of service and can be unstable; and second, Pods that request too many or too few resources, starving other applications or being inefficient. LimitRange enforces resource boundaries on a per-Pod/Container basis.
THE MENTAL MODEL: Think of LimitRange as setting the rules for a single diner's order at a restaurant. It can enforce a 'minimum order' (min request), a 'maximum order' (max limit), and even provide a 'default combo meal' (default request/limit) if the diner doesn't specify. This is different from a ResourceQuota, which is like the restaurant's total fire code capacity.
HOW IT WORKS: You create a LimitRange object within a specific Kubernetes namespace. This object defines constraints for resources like CPU and memory. The constraints can include: minimum and maximum values for requests/limits per Pod or Container, a default request/limit to apply to containers that don't specify them, and a maximum limit/request ratio to enforce resource usage patterns. When a Pod is submitted to the API server, it's validated against the LimitRange of its namespace. If it violates the constraints, it's rejected. If it's missing requests or limits, the defaults are applied automatically.
WHEN TO USE IT: Use LimitRange in any multi-tenant or shared namespace to ensure fairness and prevent 'noisy neighbor' problems. It's also essential for enforcing operational best practices by automatically assigning resource requests to all Pods, which improves scheduling decisions and overall cluster stability. It helps standardize resource allocation across teams.
WHEN NOT TO USE IT: LimitRange is less critical in small, single-user clusters where the operator has full control and trusts all workloads. Do not use it if you want to cap the total resource consumption of a namespace; that is the job of a ResourceQuota. Using a LimitRange alone will not prevent a user from creating a thousand small Pods that collectively exhaust namespace resources.
ONE CANONICAL EXAMPLE: A common use case is to set default resource requests and limits. A LimitRange can be configured to automatically apply a request of 100m CPU and 128Mi memory, and a limit of 500m CPU and 512Mi memory to any container that is created without these values explicitly defined in its manifest. This ensures every container has a guaranteed resource slice and a hard cap, preventing both instability and runaway consumption.
Read the original → kubernetes.io
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.