Understanding QoS Classes: Guaranteed vs Burstable vs BestEffort in Kubernetes
Intermediate · 3 min read
The Problem
Imagine you are a DevOps engineer responsible for managing a microservices-based application on Kubernetes. Your application has several components, each with different resource requirements and criticality levels. You need to ensure that the most critical services, such as your payment processing system, always have the resources they need, while less critical services, like logging, can be more flexible. How do you achieve this balance? This is where Kubernetes Quality of Service (QoS) classes come into play.
QoS classes help you manage how Kubernetes allocates and prioritizes resources among different pods. By understanding and using these classes, you can ensure that your critical services get the resources they need, even under high load, while less critical services can still run efficiently without starving the system.
Core Concepts
Before diving into the details, let’s define some key terms:
- Pod: The smallest deployable unit in Kubernetes. A pod can contain one or more containers.
- Resource Requests and Limits: These are the minimum and maximum resources (CPU and memory) that a container can request and use, respectively.
- Quality of Service (QoS) Classes: These determine how Kubernetes treats pods in terms of resource allocation and eviction policies. There are three QoS classes: Guaranteed, Burstable, and BestEffort.
How It Works
Kubernetes uses the QoS classes to make decisions about pod scheduling and eviction. Here’s a breakdown of each class:
- Guaranteed: Pods in this class have both CPU and memory requests and limits set, and they are equal. Kubernetes guarantees that these pods will always get the requested resources. They are the highest priority and are the last to be evicted.
- Burstable: Pods in this class have resource requests and limits set, but they are not equal. Kubernetes tries to allocate the requested resources, but if there is extra capacity, the pods can use up to their limits. They are lower priority than Guaranteed pods but higher than BestEffort.
- BestEffort: Pods in this class have no resource requests or limits set. Kubernetes does not guarantee any specific resources for these pods. They are the lowest priority and are the first to be evicted if the node is under pressure.
Prerequisites
To follow this tutorial, you need:
- A running Kubernetes cluster (e.g., Minikube, GKE, EKS, AKS).
- kubectl installed and configured to interact with your cluster.
- Basic understanding of Kubernetes concepts (pods, containers, deployments, etc.).
Hands-On Walkthrough
Let’s create and deploy pods with different QoS classes to see how they behave.
1. Create a Guaranteed QoS Pod
kubectl apply -f - <<EOF apiVersion: v1 kind: Pod metadata: name: guaranteed-pod spec: containers: - name: guaranteed-container image: nginx resources: requests: memory:
References
This article was written with AI assistance.
