Resource Requests & Limits
Requests reserve CPU and memory for a container; limits cap how much it may use.
To schedule Pods wisely and stop one container from starving others, you declare how much CPU and memory each container needs.
Requests vs limits
- request — the amount guaranteed to the container. The scheduler uses it to pick a node with enough room.
- limit — the ceiling. A container using more memory than its limit is killed (OOMKilled); exceeding the CPU limit just throttles it.
Units
CPU is measured in cores; 500m means 0.5 of a core ("m" = millicores). Memory uses bytes with suffixes like Mi (mebibytes) and Gi (gibibytes).
Quality of Service
Setting requests equal to limits gives a Pod the highest-priority Guaranteed QoS class, making it the last to be evicted under pressure.
Example
apiVersion: v1
kind: Pod
metadata:
name: sized-app
spec:
containers:
- name: app
image: myapp:1.0
resources:
requests:
cpu: "250m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "256Mi"When to use it
- A team sets memory limits on all containers so that a memory-leaking pod is OOMKilled and restarted rather than taking down the entire node.
- A platform team applies LimitRange defaults to a namespace so that developers cannot accidentally deploy unlimited containers that starve other workloads.
- An SRE reviews ResourceQuota usage to ensure a team's namespace does not exceed the allocated CPU and memory budget in a multi-tenant cluster.
More examples
Container resource requests and limits
Sets CPU and memory requests (scheduler guarantee) and limits (enforcement ceiling) on a container.
spec:
containers:
- name: api
image: myapi:1.0
resources:
requests:
cpu: "250m"
memory: "128Mi"
limits:
cpu: "1"
memory: "512Mi"LimitRange for namespace defaults
Creates a LimitRange that automatically applies default resource requests and limits to any container without explicit values.
apiVersion: v1
kind: LimitRange
metadata:
name: default-limits
namespace: dev
spec:
limits:
- type: Container
default:
cpu: "500m"
memory: "256Mi"
defaultRequest:
cpu: "100m"
memory: "64Mi"ResourceQuota per namespace
Enforces a hard cap on total CPU, memory, and pod count in the dev namespace to prevent resource exhaustion.
apiVersion: v1
kind: ResourceQuota
metadata:
name: dev-quota
namespace: dev
spec:
hard:
requests.cpu: "4"
requests.memory: 8Gi
limits.cpu: "8"
limits.memory: 16Gi
count/pods: "20"
Discussion