Not setting resources leads to unpredictable behavior. Requests guarantee minimum, Limits cap maximum.
Understanding the Difference:
– Requests: Guaranteed resources (used for scheduling)
– Limits: Maximum resources (hard cap)
Example Configuration:
apiVersion: v1
kind: Pod
metadata:
name: myapp
spec:
containers:
- name: app
image: myapp:1.0
resources:
requests:
memory: "256Mi"
cpu: "250m" # 0.25 CPU core
limits:
memory: "512Mi"
cpu: "500m" # 0.5 CPU core
What Happens:
– Scheduler finds node with at least 256Mi RAM + 0.25 CPU available
– Pod gets guaranteed 256Mi + 0.25 CPU
– If pod tries to use >512Mi RAM → OOMKilled
– If pod tries to use >0.5 CPU → Throttled (not killed)
Best Practice: Set requests = normal usage, limits = peak usage
CPU Units: 1 = 1 CPU core, 100m = 0.1 core
