Phase 5: Platform Engineering

Pod disruption budgets, resource quotas & limit ranges

Advanced ~2 min read
Think of it this way A friendly analogy. Read this if the technical version feels dense. Show Hide

Imagine a huge room filled with awesome building blocks. This giant room is where everyone builds their cool projects. Now, sometimes the grown-ups need to do some cleaning or rearrange the tables in the room. If your team is building a super-important rocket that needs to be visible all the time, even when a table is being moved, you wouldn't want someone to just knock down your whole rocket, right? This is where Pod Disruption Budgets come in. It’s like putting a special rule on your rocket that says, "Hey! If you need to move the table, you can only take down one piece of the rocket at a time, making sure at least three pieces are always standing. Don't let my rocket totally disappear!" This way, your critical rocket stays mostly built, even during planned clean-ups.

Now, with all those blocks, what if one friend decides to build a gigantic castle that uses every single block in the room? Then nobody else could build anything! To stop that, there are Resource Quotas. These are like assigning each team a special box. The grown-ups say, "Okay, Team Green, your box can hold up to 100 blue blocks and 50 red blocks. You can't take more than that for all your projects combined." This ensures everyone gets a fair share of the building blocks and no single team can hog everything.

But what about inside your team's box? Let's say your Team Green is building a city, with many small houses and cars. You might want to ensure no single tiny house accidentally becomes a giant skyscraper. Or what if you forget to say how many blocks a little car needs? Limit Ranges are like extra guidelines for the individual structures within your project. They might say, "Any small house you build must use at least 5 blocks, but no more than 15." Or "If you don't specify, each car automatically gets 7 blocks." This prevents individual parts of your project from being too greedy or too small, helping you build more effectively.

So, when you're managing a big building block room where many teams are creating awesome things, these rules help you keep everything running smoothly. You can make sure your most important creations are always visible, that everyone gets a fair share of blocks, and that each part of a project uses just the right amount, making for a much smoother and fairer building experience.

For SREs, ensuring critical application uptime during Kubernetes cluster maintenance is paramount. Pod Disruption Budgets (PDBs) are your primary tool for guaranteeing a minimum number of healthy application instances remain available during voluntary disruptions like node drains, cluster upgrades, or autoscaling events. Instead of merely hoping your application can tolerate a node being taken offline, a PDB explicitly defines a minAvailable (e.g., 70% or 3 replicas) or maxUnavailable (e.g., 1 replica) threshold for a set of pods. The Kubernetes scheduler and cluster autoscaler respect PDBs, preventing operations that would violate these availability guarantees, thus safeguarding your application's reliability during planned changes.

Managing multi-tenant or shared Kubernetes clusters demands robust resource governance. Resource Quotas provide this by allowing SREs to set limits on the total compute resources (CPU, memory), storage resources, and even the count of Kubernetes objects (e.g., pods, services, persistentvolumeclaims) within a specific namespace. This prevents a single team or application from monopolizing cluster resources, ensuring fair sharing and mitigating the "noisy neighbor" problem. By configuring quotas, you can enforce budget constraints, prevent resource exhaustion, and maintain overall cluster stability, which are crucial for consistent performance and predictable operational costs.

While Resource Quotas manage the aggregate resource consumption in a namespace, Limit Ranges operate at the pod and container level. An SRE can use Limit Ranges to enforce default resource requests and limits for pods if they aren't explicitly specified, preventing poorly configured applications from running without any resource boundaries. Furthermore, Limit Ranges can define the minimum and maximum CPU/memory requests and limits allowed for any pod or container within that namespace. This creates guardrails, ensuring that even if users specify resources, they fall within acceptable operational parameters, complementing Resource Quotas by ensuring individual components adhere to sensible resource profiles.

Key Takeaways

  • PDBs: Essential for maintaining application availability during planned cluster maintenance and upgrades.
  • Resource Quotas: Enforce namespace-level resource governance, preventing resource exhaustion and "noisy neighbors."
  • Limit Ranges: Define pod/container-level resource defaults and constraints, complementing quotas for granular control.
  • Together, these ensure cluster stability, fairness, and predictable application behavior in shared environments.

Code Example

yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: team-a-dev-quota
  namespace: team-a-dev
spec:
  hard:
    pods: "10"
    requests.cpu: "2"
    requests.memory: "4Gi"
    limits.cpu: "4"
    limits.memory: "8Gi"
    persistentvolumeclaims: "5"
    requests.storage: "50Gi"

How this code works

This Kubernetes YAML defines a ResourceQuota named team-a-dev-quota for the team-a-dev namespace. Its primary purpose is to enforce limits on the total resources that pods and other Kubernetes objects can consume within this specific namespace. This mechanism ensures fair resource distribution and prevents any single team or application from monopolizing cluster resources, which is crucial for maintaining stability and predictability in a shared SRE environment.

The spec.hard section specifies the strict upper bounds for various resources. For instance, pods: "10" dictates that no more than 10 pods can be running simultaneously in the team-a-dev namespace. requests.cpu: "2" and requests.memory: "4Gi" set the cumulative maximum for all pod resource requests—these are the guaranteed minimums for CPU and memory that Kubernetes aims to provide. Similarly, limits.cpu: "4" and limits.memory: "8Gi" define the cumulative maximum for all pod resource limits—the absolute ceiling for CPU and memory usage. A subtle but important aspect is that for a pod to be admitted into the namespace, it must satisfy both the total requests.* and the total limits.* quotas simultaneously. Finally, persistentvolumeclaims: "5" and requests.storage: "50Gi" cap the number and total storage requested by persistent volume claims, managing disk space consumption.