I speak here {^_^}

Quality of Service for Pods #29

August 03, 2021

While working on a side project yesterday, I was reading through the Pod manifests for some services. And one of the fields, I read there was qosClass: BestEffort.

I might be very ignorant before (as I never paid attention to this), but I wanted to understand what this QoS class (or Quality of Service class) meant.

So, yea below is what I understood & it is a very easy concept. 🙂


So, when we create pods in a kubernetes cluster, kubernetes assigns one of following QoS classes to (every) Pod:

  • Guaranteed
  • Burstable
  • BestEffort

Each of these QoS class listed above have something to do with whether the Pod objects have properly defined resources (CPU, memory) or not.

Guaranteed

A Pod (including all the init containers and app containers) will get a QoS class of Guaranteed, if:

apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  namespace: default
spec:
  containers:
  - name: test-container
    image: nginx
    resources:
      limits:
        memory: "50Mi"
        cpu: "200m"
      requests:
        memory: "50Mi"
        cpu: "200m"
  • Every Container in the Pod must have a memory limit and a memory request set.
  • For every Container in the Pod, the memory limit must be equal to the memory request.

    For example ~

    • limits(memory) = requests(memory) = 50 Mi
  • Every Container in the Pod must have a CPU limit and a CPU request.
  • For every Container in the Pod, the CPU limit must equal the CPU request.

    For example ~

    • limits(cpu) = requests(cpu) = 200m

Burstable

A Pod will get a QoS class of Burstable, if:

apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  namespace: default
spec:
  containers:
  - name: test-container
    image: nginx
    resources:
      limits:
        memory: "50Mi"
      requests:
        memory: "100Mi"
  • The Pod does not meet the criteria for QoS class Guaranteed.
  • At least one Container in the Pod has a memory or CPU request.

    For example ~

    • requests(memory) > limits(memory)

BestEffort

A Pod will get a QoS class of BestEffort, if:

apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  namespace: default
spec:
  containers:
  - name: test-container
    image: nginx
  • The containers in the Pod must not have any memory or CPU limits or requests.