Requests and limits do one more thing: they put the Pod into a Quality of Service class. The class is computed when the Pod is created and stored in status.qosClass.
The three classes
| Class | Rule | Evicted |
|---|---|---|
Guaranteed | every container has requests equal to limits for cpu and memory | last |
Burstable | something is set, but not that | in between |
BestEffort | no requests and no limits anywhere in the Pod | first |
Eviction is different from OOMKilled. OOMKilled is one container passing its own limit. Eviction is the node running short and the kubelet removing whole Pods to recover, starting with the ones that promised nothing.
Reading it
kubectl get pod market-db -o jsonpath='{.status.qosClass}'
kubectl describe pod market-db | grep QoSQoS Class: GuaranteedChoosing
A database wants Guaranteed: it should be the last thing to go, and it should never be throttled by a neighbour. A web tier is usually Burstable: a request it can count on, a limit above it for spikes. BestEffort is for things you would not mind losing, and a Deployment created with kubectl create deployment is exactly that until you add resources.
kubectl set resources deploy/market-db --requests=cpu=250m,memory=256Mi --limits=cpu=250m,memory=256MiEqual numbers on both sides, and the next Pod is Guaranteed.