Do you know about Quality of Service in Kubernetes??

The kube guy
Google Cloud - Community
3 min readMay 23, 2024

In this article let’s get to know about Quality of Service (QoS) in Kubernetes. Btw I’ve taken some liberty to compare the whole scenario with a party that’s happening in hotel. Here it goes like this

You’re working as a manager in a luxurious hotel. You have three types of guests: the royals, the rich, and the regular folks. Let’s see how you manage these guests without losing your sanity.

Let’s get to the point straight, here how your three types of guests were treated..

The Hotel Guests (Pods)

  1. Guaranteed Guests: These are the royals. They booked the presidential suite, demanded a caviar breakfast, and a private butler. They paid a fortune, and if you don’t meet their demands, they’ll ruin your reputation. In Kubernetes, these are the pods with specific resource limits and requests that match. They get the highest priority.
apiVersion: v1
kind: Pod
metadata:
name: royal-pod
namespace: hotel-namespace
spec:
containers:
- name: royal-container
image: myimage
resources:
requests:
memory: "1Gi"
cpu: "1"
limits:
memory: "1Gi"
cpu: "1"
  • This configuration ensures that the pod royal-pod in the hotel-namespace gets exactly 1Gi of memory and 1 CPU.
  • Both requests and limits are set to the same values, guaranteeing the pod these resources.

2. Burstable Guests: These are the rich folks. They booked a deluxe room and said, “We usually take the suite, but we’ll settle for this. Oh, but if the suite is free, we’d love to upgrade!” They pay well but expect flexibility. These pods have set limits and requests, but their limits are higher than their requests.

apiVersion: v1
kind: Pod
metadata:
name: rich-pod
namespace: hotel-namespace
spec:
containers:
- name: rich-container
image: myimage
resources:
requests:
memory: "512Mi"
cpu: "0.5"
limits:
memory: "1Gi"
cpu: "1"
  • This configuration for the pod rich-pod in the hotel-namespace sets a baseline (requests) of 512Mi memory and 0.5 CPU, but allows the pod to use up to 1Gi memory and 1 CPU if available (limits).
  • It provides flexibility, letting the pod burst to higher resource usage when possible

3. Best-Effort Guests: These are the regular folks who showed up at the last minute. They said, “Got any room? We’re not picky.” They get whatever is left after the royals and rich folks have taken their share. In Kubernetes, these pods have no set resource limits or requests.

apiVersion: v1
kind: Pod
metadata:
name: regular-pod
namespace: hotel-namespace
spec:
containers:
— name: regular-container
image: myimage
  • This configuration for the pod regular-pod in the hotel-namespace has no resource requests or limits specified.
  • The pod will run using whatever resources are left after higher priority pods are allocated their resources, making it the lowest priority for resource allocation.

Conclusion

QoS is a great feature when used correctly, here are few tips from my side on how to effectively use this feature and make your application run smoothly.

Use Guaranteed QoS for mission-critical applications that require consistent and reliable performance.Opt for Burstable QoS for applications that can handle some flexibility but still need good performance under normal conditions. Reserve Best-Effort QoS for non-essential services or experimental projects that can tolerate resource shortages.

Avoid using Guaranteed QoS for less critical applications, as it can lead to resource wastage. Similarly, refrain from using Best-Effort QoS for important services, as they risk being starved of resources during peak demand. By strategically assigning QoS, you ensure your Kubernetes cluster runs smoothly, balancing performance and resource efficiency.

A huge thank you to all my readers for helping me cross 1,000 followers! Your support means the world to me. If you’ve been enjoying my content, please subscribe to my newsletter so that you won’t miss any of articles. If this is your first time here, consider following The kube guy for more articles like this. Your engagement keeps me motivated to bring you the best content possible and always for free.

--

--

The kube guy
Google Cloud - Community

I'll help you sail through the ocean of Kubernetes with minimal efforts