Kubernetes: Quality of Service
September 22, 2019
Kubernetes wants to manage the pods in a way that ensures the best quality of service, therefore, it categorizes the pods in three different categories to be able to perform tasks like scheduling and evicting.
- Guaranteed
- Burstable
- BestEffort
Based on the requests
and limits
for every container in the pod.
Defining the QoS class for a pod
Guaranteed
Guaranteed
is like a first-class citizen pod, and must meet two conditions
- Every container in the pod must have memory and CPU specified.
- They must be equal.
BestEffort
BestEffort
class for the pods which you didn’t specify any resources
or limits
for every container in the pod.
Burstable
Burstable
class is something in the middle. So if the pod is not Guaranteed
nor BestEffort
, Then it is Burstable
Checkout the actual implemtation
which pod gets killed first?
Kubelets keeps monitoring the node for low resources and when that happens it evicts a pod.
The QoS classes determine which pod gets evicted first.
The priority for the killing goes to BestEffort
, followed by Burstable
, and finally Guaranteed
.
But what happens to the pods with the same QoS class? Kubernetes uses the memory resource to determine which one gets evicted first. Because the memory is an incompressible resource and can cause failure to the whole node. So it calculates a score for every process then the process with the highest score gets killed. This score is calculated approximately by summing the amount of memory the process consumes multiplied by 10 to a number based on the QoS class. checkout OOMScore function