Decoding Kubernetes Resource Allocation with QoS Classes

Good day. It's Monday, Sep. 16, and in this issue, we're covering:

  • Decoding Kubernetes Resource Allocation with QoS Classes

  • Microsoft introduces o1-preview and o1-mini, newest OpenAI Models

  • New Linux malware Hadooken targets Oracle WebLogic servers

  • Secrets Management Core Practices

  • CNCF Online Program: From serverless to K8s

  • DevOps Interview Questions for Meta, Amazon, Google, Yahoo

Use Case

Decoding Kubernetes Resource Allocation with QoS Classes

I recently spent some time breaking down how Kubernetes allocates resources to containers. If you’ve ever wondered how CPU and memory limits work in Kubernetes or felt frustrated when a container unexpectedly consumed all available resources, you’re not alone.

Let's walk you through four distinct QoS classes in Kubernetes—think of it as a resource allocation game where containers either play nice or, well, don’t.

This is your wild-west scenario. Imagine running a web scraper like Selenium in a Kubernetes pod without setting any CPU or memory limits. The container uses as much CPU as it wants. At first, everything runs fine, but as soon as the scraping workload increases, the CPU consumption skyrockets.

Now, your other services—like that Redis cache—start experiencing slow response times because the scraper is monopolizing the CPU.

Practical Tips:

  • Always set limits for services with unpredictable workloads.

  • Monitor resource usage with tools like Prometheus.

  • Start with modest limits and adjust based on performance data.

Think of this like managing a database in production. Let’s say you have a PostgreSQL database that’s mission-critical. You want this database to always have a guaranteed amount of CPU and memory so it doesn’t crash when demand spikes.

In Kubernetes, you’d use Guaranteed QoS for this pod by setting equal CPU and memory requests and limits.

Practical Tips:

  • Use Guaranteed QoS for critical services like databases or payment systems.

  • Set equal requests and limits for stable performance, especially during peak loads.

Let’s say you run a batch job every night to process log data from multiple microservices. During the day, this container doesn’t need much CPU because it’s idle. But at night, when the batch job kicks in, the container could benefit from additional CPU if it’s available. That’s where Burstable QoS comes into play.

The job can burst beyond its initial requests if resources are free, making it efficient without disrupting other services.

Practical Tips:

  • Use Burstable QoS for jobs that need extra resources occasionally, like batch jobs.

  • Make sure other critical services aren't competing for the same burstable resources.

This is the lowest priority class, meaning the container will only get resources if there’s anything left over. Think of a logging or metrics collector—it doesn’t need a lot of CPU, and it can handle some variability in performance.

Best Effort containers may get pushed aside if more important services need the resources.

Practical Tips:

  • Use Best Effort QoS for non-critical services like logging or background tasks.

  • Avoid this class for anything that needs consistent performance.

Remember, setting the right QoS in Kubernetes is crucial—without it, one container can consume all resources, disrupting your entire system's stability.

2024 is 71% complete. Start the idea you’ve been holding.

Tool Of The Day

skupper  - A layer 7 service interconnect. It enables secure communication across Kubernetes clusters with no VPNs or special firewall rules.

Trends & Updates

Resources & Tutorials

Picture Of The Day

Did someone forward this email to you? Sign up here

Interested in reaching smart techies?

Our newsletter puts your products and services in front of the right people - engineering leaders and senior engineers - who make important tech decisions and big purchases.