KubernetesCIX · LimitRangeLimitRange
Min and max constraints — bounding what containers can request
What you'll learn
- Configure min and max constraints
- Apply maxLimitRequestRatio for overcommit bounds
- Reason about the admission behaviour
- Apply the operational discipline of setting constraints appropriately
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
Min and max constraints in LimitRange bound what containers can request. This lesson walks the constraints, the admission behaviour, the overcommit ratio, and the discipline.
The min and max fields
apiVersion: v1
kind: LimitRange
metadata:
name: container-limits
namespace: tenant-a-prod
spec:
limits:
- type: Container
default:
cpu: 500m
memory: 512Mi
defaultRequest:
cpu: 100m
memory: 128Mi
max:
cpu: 2
memory: 4Gi
min:
cpu: 50m
memory: 64Mi
maxLimitRequestRatio:
cpu: "4"
memory: "2"
The constraint fields:
- max. Maximum limits a container can specify. A container requesting 4 cores would be rejected if max is 2.
- min. Minimum requests a container must specify. A container requesting 10m CPU would be rejected if min is 50m.
- maxLimitRequestRatio. Maximum ratio of limit to request. A container with limit=4 and request=10m (ratio 400x) would be rejected if maxLimitRequestRatio is 4.
The admission behaviour
flowchart LR
A[Pod creation request] --> B{Container within min?}
B -->|No| C["Rejected: below min"]
B -->|Yes| D{Container within max?}
D -->|No| E["Rejected: above max"]
D -->|Yes| F{ratio within maxLimitRequestRatio?}
F -->|No| G["Rejected: ratio exceeded"]
F -->|Yes| H[Accepted]
The admission sequence:
- Each container’s requests are checked against
min. Below min → rejected. - Each container’s limits are checked against
max. Above max → rejected. - The ratio of limit to request is checked against
maxLimitRequestRatio. Above → rejected. - If all checks pass, the Pod is accepted.
The overcommit ratio
flowchart LR
A[Container] --> B["Request: 100m"]
A --> C["Limit: 500m"]
B --> D["Ratio: 5x"]
D --> E{maxLimitRequestRatio: 4}
E -->|5 > 4| F[Rejected]
E -->|4x ratio| G[Accepted]
The ratio prevents extreme overcommit. A container with limit=4 cores and request=10m (ratio 400x) is allowed to burst to 4 cores but reserves almost nothing. The scheduler would overpack the node, and the container would frequently throttle.
A maxLimitRequestRatio of 4 (or 2 for memory)
prevents this extreme case.
The min field
min:
cpu: 50m
memory: 64Mi
The min field ensures every container declares some
resources. A Pod with resources.requests: {} would
have zero requests and be invisible to the scheduler
(and the quota).
The min field is applied as the floor for any
declared request. A container with requests.cpu: 10m would be rejected if min is 50m.
The max field
max:
cpu: 2
memory: 4Gi
The max field prevents one container from consuming the entire namespace quota. A 64-core container in a 32-core namespace quota would fail at admission (the quota is checked too).
The max is a per-container limit. A namespace with 10 containers, each at 2 cores, would be within a 20-core quota.
The maxLimitRequestRatio
maxLimitRequestRatio:
cpu: "4"
memory: "2"
The ratio is per resource. CPU can typically be overcommitted more aggressively than memory (CPU throttling is graceful; memory OOM is fatal).
A typical configuration:
- CPU: 4. A container with limit=2 cores can have request as low as 500m (4x ratio).
- Memory: 2. A container with limit=2Gi can have request as low as 1Gi (2x ratio).
Quiz
Knowledge check · 4 questions
Q1. What does `maxLimitRequestRatio` constrain?
Q2. A container with a very small request and a very large limit can be scheduled onto an already-busy node.
Q3. A Deployment is rejected for its limit-to-request ratio; decide which of the two numbers should change.
A new `feature-flags` Deployment in `platform-prod` is rejected at admission with `cpu max limit to request ratio per Container is 4, but provided ratio is 20.000000`. The container declares `requests.cpu: 100m` and `limits.cpu: 2`. `kubectl describe limitrange container-limits -n platform-prod` shows `max cpu 2`, `min cpu 50m`, and `maxLimitRequestRatio cpu 4`.
Q4. A Container LimitRange sets `max.cpu: 2` and no `default`. What CPU limit and request does a container that declares no resources at all receive?
Passing score: 75%. Answers are checked in this browser.
The operational discipline
Min and max constraints in production rest on five non-negotiable elements:
- Set max for every resource. Prevent monopolisation.
- Set min to ensure declarations. Pods without requests are invisible.
- Set maxLimitRequestRatio. Prevent extreme overcommit.
- Tune based on workload characteristics. Memory-constrained workloads need tighter memory ratios.
- Test the constraints. Quarterly: create a Pod that exceeds max; verify rejection.
Constraints are the guardrails. Without them, a single workload can disrupt the entire namespace.