Skip to content
tezvyn:
Menu

ResourceQuota: Namespace Resource Budgets

Source: kubernetes.ioMediumHow cards are made

ResourceQuota: Namespace Resource Budgets

ResourceQuota is a namespace budget: it rejects pods once total requests hit the cap. Use it to keep multi-tenant clusters fair. The footgun: it counts requested resources, not real usage, and pods missing requests may be rejected without LimitRange defaults.

Why it exists

Kubernetes clusters are shared infrastructure. Without guardrails, one team or application can create unlimited pods, services, or persistent volume claims, exhausting node capacity or the control plane's object store. ResourceQuota was designed to give cluster administrators a policy lever to cap aggregate consumption at the namespace boundary, ensuring fair sharing and preventing resource starvation across tenants.

The mental model

Think of a namespace as a shared apartment and ResourceQuota as the lease agreement that sets maximums. It does not throttle running workloads; it blocks the front door. Once the cumulative resource requests or object counts in that namespace reach the ceiling, the API server refuses to admit anything new. It is a hard budget, not a speed limit.

How it works

A cluster administrator creates a ResourceQuota object in a target namespace. The object specifies hard limits for compute resources such as CPU and memory, storage resources like persistent volume claims, and object counts including pods, services, configmaps, secrets, and replication controllers. The ResourceQuota admission controller intercepts creation and update requests. If the action would cause the namespace to exceed any defined hard limit, the API server returns a 403 Forbidden status and the operation fails. Quotas are calculated using the resource requests and limits specified in pod and container specs, not observed utilization metrics.

When to use it

Use ResourceQuota in any multi-tenant or multi-team cluster where namespaces map to organizational boundaries. It is also valuable in development or sandbox environments to prevent runaway CI jobs or accidental infinite loops from provisioning thousands of objects. If you charge back infrastructure costs by namespace, quotas enforce the contractual spending limit.

When not to use it

Do not use ResourceQuota as a runtime performance throttle. It does not reduce CPU or memory for running pods when utilization spikes. It also cannot protect against actual node-level exhaustion if pods use far less than their requested limits; a node can still run out of physical memory even when the namespace quota is nowhere near its cap. For runtime throttling, use limits on containers or quality of service classes. Do not rely on ResourceQuota alone if your workloads frequently omit resource requests, because the admission controller may reject otherwise valid pods.

One canonical example

A platform team runs a cluster for three engineering groups, each with their own namespace. They create a ResourceQuota in the payments namespace that allows twenty pods, a total of forty CPU cores in requests, and one hundred gigabytes of memory in requests. A developer submits a deployment with a replica count of twenty-five. The first twenty pods are admitted, but the twenty-first pod is rejected by the API server with a forbidden error because the pod count hard limit was reached. The developer must either delete old pods or request a quota increase from the platform team.

Interview question

A namespace has a 100 GiB memory ResourceQuota. Pod requests total 80 GiB, but node memory is 95% utilized. A new pod requests 10 GiB. What is the result?

  • a.The pod is admitted because requests are under the cap, though the node may still exhaust memory.Correct
  • b.The pod is rejected because the quota tracks actual memory usage rather than pod requests.
  • c.The pod is rejected because high node utilization overrides ResourceQuota.
  • d.The pod is admitted, but ResourceQuota OOMKills running pods if namespace usage later exceeds the cap.
Why?

ResourceQuota acts at admission time and counts resource requests, not live node metrics, so the pod is admitted while the node remains at risk. Distractor A is wrong because node pressure does not override quota, and B is wrong because quota never terminates or throttles already-running workloads.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles