Skip to main content

ResourceQuota

A ResourceQuota is a namespace-scoped Kubernetes object that sets hard limits on total compute resources and object counts in a namespace. It protects shared clusters so one team or runaway workload cannot consume everything.

What it limits

  • Compute totals: requests.cpu, requests.memory, limits.cpu, limits.memory.
  • Object counts: pods, services, secrets, configmaps, PVCs.
  • Service types: for example block NodePorts or cap LoadBalancers.
flowchart TD C["Cluster capacity"] --> A["payments namespace
32 CPU quota"] C --> B["risk namespace
16 CPU quota"] C --> D["data namespace
64 CPU quota"] classDef cluster fill:#475569,color:#ffffff classDef ns fill:#DBEAFE,color:#1E293B class C cluster class A,B,D ns

Example

YAML
apiVersion: v1
kind: ResourceQuota
metadata:
name: payments-team-quota
namespace: payments-prod
spec:
hard:
requests.cpu: "32"
requests.memory: 128Gi
limits.cpu: "64"
limits.memory: 256Gi
pods: "100"
services: "20"
secrets: "50"
persistentvolumeclaims: "20"
services.loadbalancers: "3"
services.nodeports: "0"

What happens at the limit

Quota is enforced at admission. A request that would exceed it is rejected immediately with a Forbidden error, rather than queued.

TEXT
Error from server (Forbidden): pods "api-server" is forbidden:
exceeded quota: payments-team-quota, requested: requests.memory=4Gi,
used: requests.memory=126Gi, limited: requests.memory=128Gi

If a quota covers CPU or memory, every pod must declare matching requests and limits, otherwise it is rejected. A LimitRange can inject defaults so developers do not have to.

Bash
kubectl get quota -n payments-prod
kubectl describe quota payments-team-quota -n payments-prod

Troubleshooting

Symptom Likely cause Fix
exceeded quota on apply A resource is exhausted Free capacity or raise the quota
must specify requests Pod has no resources block Add resources or a LimitRange
ReplicaSet cannot create pods Quota hit during scale-up Read ReplicaSet events
Tip

Alert on quota usage above 80 percent. A deploy or HPA scale-up that fails on quota during an incident is painful.

Security

services.nodeports: "0" blocks NodePort exposure in shared clusters, keeping traffic on approved ingress paths.

Common Mistake

Limiting only requests and not limits. A container can request little but set a huge limit, bypassing the intent of the quota.

Frequently Asked Questions

Does a ResourceQuota work if pods have no requests?

Not for the resources it tracks. Pods without declared requests and limits are rejected, which is why quotas are usually paired with a LimitRange supplying defaults.

What happens when a quota is hit?

New objects are refused at admission with a Forbidden error. Existing pods keep running. Controllers like Deployments surface the failures in their events.

ResourceQuota or LimitRange?

Quota caps the namespace total. LimitRange bounds each container or PVC. Production namespaces typically use both.

Found a mistake, an outdated step or a broken link?