Kubectl Requests and Limits

Right-size pods so scheduling is predictable and nodes survive.

  • resource requests
  • resource limits
  • OOMKilled
  • kubectl top
  • right-size pods

Kubectl Requests and Limits

Right-size pods so scheduling is predictable and nodes survive.

Commands

CommandWhat it does
`kubectl describe nodegrep -A5 Allocated`Node capacity vs allocation
kubectl top pods --sort-by=memoryBiggest memory users first
kubectl set resources deploy/api --requests=cpu=200m,memory=256MiSet requests live
`kubectl describe pod <p>grep -A3 Limits`Verify applied values

Example

kubectl top pods -n shop --sort-by=memory
kubectl set resources deploy/api --requests=cpu=200m,memory=256Mi --limits=cpu=1,memory=512Mi
kubectl describe node | grep -A5 Allocated

FAQ

requests vs limits?

Requests drive scheduling (guaranteed); limits cap bursts (throttle CPU, kill on memory overuse).

Why was my pod OOMKilled?

It exceeded its memory limit — raise the limit or fix the leak; check Last State in describe.

常见问题

requests vs limits?
Requests drive scheduling (guaranteed); limits cap bursts (throttle CPU, kill on memory overuse).
Why was my pod OOMKilled?
It exceeded its memory limit — raise the limit or fix the leak; check Last State in describe.

Kubernetes