How to Effectively use Kubernetes Quality of Service

Published: October 6, 2021 by Author's Photo Shane Rainville | Reading time: 3 minutes.
Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

Quality of Service is a feature introduced in Kubernetes 1.22 that allows resource profiles to be applied to pods. As of this release there are three profiles available:

  • Guaranteed
  • Burstable
  • BestEffort

Profiles are applied to pods based on how they are configured, and each profile has its own strength and weaknesses you will need to understand to fully leaverage the capabilities they offer.

Quality of Service Profiles

Guaranteed

The Guaranteed QoS profile ensure that a pod is scheduled on a node with enough resources to run. The profile is applied to a pod when the request values and limit values are equal.

Benefits: This profile quarantees a pod will have sufficient memory and CPU on any node it is scheduled on; There is no risk of a scheduled pod experiencing resource contention.

Risks: Pods with this profile will only be scheduled when a node has sufficient resources available. If no nodes in your node pools have enough resources the pod will not be scheduled, potentially leading to a service outage.

Pod that applies the Guaranteed QoS profile:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  namespace: prod
spec:
  containers:
  - name: qos-demo-4-ctr-1
    image: nginx
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "200Mi"

Burstable

The Burstable QoS profile allows a pod to consume more resources than are requested. However, when being scheduled there is no quarantee the node will have enough resources available for its containers to run.

The profile is assigned to pods where the resource limit values do not match the resource request values. During scheduling, a pod will be placed on a node that meets its request values, however, there is no guarantee the node will have enough resources to meet the resource limit values.

Benefits: The profile allows pods to consume more resources than they request. This extends their range of nodes they can be scheduled on without reserving more memory than is typically needed.

Risks:

  • Resource Contention: When using burstable profiles there is risk of resource contention on a node, as there is no guarantee the node has enough resources to offer a pod.

  • Evication: When deciding which pods to evict when a node is under pressure, pods with resource requests values that do not equal their resource limit values.

Pod that applies the Burstable QoS profile:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  namespace: prod
spec:
  containers:
  - name: qos-demo-4-ctr-1
    image: nginx
    resources:
      limits:
        memory: "400Mi"
      requests:
        memory: "200Mi"

BestEffort

The BestEffort policy allows for pods to be scheduled on any node, whether there are enough resources to run its applications or not.

Benefits This profile allows for the largest range of node pools a pod can be scheduled on. It is best used for apps or services that are not sensitive to evictions.

Risks:

  • Resource Contention: Pods running with the BestEffort policy have no set resource limits set. Therefore, they are capable of consuming a significant amount of resources, starving other pods.

  • Evication: Pods with the this profile are among the first to be evicted when a node experiences resource presures.

Pod that applies the BestEffort QoS Profile:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  namespace: prod
spec:
  containers:
  - name: qos-demo-4-ctr-1
    image: nginx

Conclusion

Kubernetes new Quality of Service features grants operators and application owners better control over service quality and pod evication.

By applying an effective strategy with QoS profiles you can quarantee resources for your highest priority pods, while providing best effort for those that are not as sensitive to evictions or resource contention.

Last updated on October 7, 2021 by Shane Rainville: Fix post front matter 8e98f12f5858d647e0166e425d28a87c494d8d7f
Author Photo
Blogger, Developer, pipeline builder, cloud engineer, and DevSecOps specialist. I have been working in the cloud for over a decade and running containized workloads since 2012, with gigs at small startups to large financial enterprises.

How to Deploy Jekyll on Kubernetes

Publised September 15, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Update Kubernetes Deployments

Publised September 11, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Configure Node-based apps in Kubernetes

Publised September 9, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Backup and Restore MongoDB Deployment on Kubernetes

Publised September 3, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Immediately Start Kubernetes CronJobs Manually

Publised September 2, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Copy Files to a Pod Container in Kubernetes

Publised August 27, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Set PHP Options for Wordpress in Docker

Publised August 27, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.

How to Solve Wordpress Redirects to Localhost 8080

Publised August 27, 2020 by Shane Rainville

Learn how to leverage Kubernete's Quality Of Service profiles to better control pod evications and resource utilization.