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
| Command | What it does | |
|---|---|---|
| `kubectl describe node | grep -A5 Allocated` | Node capacity vs allocation |
kubectl top pods --sort-by=memory | Biggest memory users first | |
kubectl set resources deploy/api --requests=cpu=200m,memory=256Mi | Set 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.
Preguntas frecuentes
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
Kubectl Config and Context
Point kubectl at the right cluster and switch contexts safely.
Kubectl Pods
Inspect pods, describe failures, and get a shell inside.
Kubectl Deployments
Create, update, and inspect Deployments that own your pods.
Kubectl Services
Expose pods stably with ClusterIP, NodePort, and LoadBalancer.