Kubernetes ResourceQuotas are how you stop one namespace from consuming a whole cluster. Without a quota, a team can deploy dozens of replicas, request far more CPU and memory than the cluster can provide, and leave other teams with pods stuck in Pending. Kubernetes ResourceQuotas set hard limits on the total resources a namespace may use, so the scheduler and the API server reject work that would exceed the budget instead of letting it starve everyone else.
This guide explains how Kubernetes ResourceQuotas work, how to create one for CPU, memory, pod count, and storage, how LimitRanges complement quotas by setting defaults and per-container bounds, and how to troubleshoot the common “exceeded quota” error. The examples use kubectl against any current Kubernetes cluster, including a local kind or minikube cluster for practice.
Prerequisites for Kubernetes ResourceQuotas
You need kubectl configured to talk to a cluster, cluster-admin or namespace-admin permission to create quota objects, and a test namespace you can safely fill up. Create one with kubectl create namespace quota-demo. You should also understand requests and limits, because quotas are enforced against the sum of pod requests and limits in the namespace, not against actual usage alone. A pod that requests 1 CPU counts as 1 CPU against the quota even if it is idle.
Quotas are a namespace-scoped resource, and they only work well when every pod in the namespace has requests and limits set. If some pods have no requests, they consume resources without counting against a CPU or memory quota, which defeats the purpose. That is exactly why LimitRanges exist, and why this guide covers both objects together.
Step 1: Create a Kubernetes ResourceQuota
A ResourceQuota is a simple YAML object. The hard section lists the maximum totals for the namespace. The example below limits the namespace to 4 CPUs of requests, 8 CPUs of limits, 8Gi of memory requests, 16Gi of memory limits, 20 pods, and 10 persistent volume claims.
apiVersion: v1
kind: ResourceQuota
metadata:
name: team-quota
namespace: quota-demo
spec:
hard:
requests.cpu: "4"
limits.cpu: "8"
requests.memory: 8Gi
limits.memory: 16Gi
pods: "20"
persistentvolumeclaims: "10"
Apply it with kubectl apply -f quota.yaml and inspect it with kubectl describe quota team-quota -n quota-demo. The describe output shows both the hard limit and the current usage, which is the fastest way to see how close a namespace is to its budget. You can also list quotas across namespaces with kubectl get quota --all-namespaces.
Once the quota exists, any new pod that would push the namespace over a hard limit is rejected by the API server with a clear “exceeded quota” message. Existing pods are not evicted when a quota is added, so adding a quota to a namespace that is already over budget does not immediately break running work — it only blocks new work until usage falls below the limit.
Step 2: Add a LimitRange for Defaults and Bounds
A LimitRange sets default requests and limits for containers that do not specify them, and it can set minimum and maximum values per container. Without defaults, a quota on requests is easy to bypass by accident, because a pod with no request counts as zero against the request quota while still using real resources. With a LimitRange, every container gets a sensible default.
apiVersion: v1
kind: LimitRange
metadata:
name: team-limits
namespace: quota-demo
spec:
limits:
- type: Container
default:
cpu: 500m
memory: 512Mi
defaultRequest:
cpu: 250m
memory: 256Mi
max:
cpu: "2"
memory: 4Gi
min:
cpu: 100m
memory: 128Mi

Apply the LimitRange with kubectl apply -f limitrange.yaml and test it by creating a pod with no resources specified, then inspecting it with kubectl get pod <name> -o yaml. You should see the default request and limit applied. Note that LimitRanges apply at creation time, so existing pods are not retroactively changed. For a shared cluster, a LimitRange plus a quota is the minimum viable guardrail, and both should be part of your namespace onboarding checklist.
Step 3: Choose Quota Values and Scope
Choosing quota values is a capacity-planning exercise, not a guess. Start from the cluster size, subtract a reserve for system pods and DaemonSets, and divide the remainder between namespaces according to priority. A common starting point for a small team namespace is a few CPUs and a few gigabytes of memory, with room to grow by request. Review quota usage monthly, because a quota that never changes becomes either a blocker or a fiction.
You can also scope quotas to specific priorities or classes using scopeSelector, for example to limit only BestEffort pods or only pods with a certain priority class. That advanced pattern is useful when a cluster runs both production and batch workloads in the same namespace, but for most teams a single unscoped quota per namespace is clearer and easier to explain to the team that hits it.
Remember that quotas count objects as well as resources. Limiting pods, services, ConfigMaps, Secrets, and persistent volume claims prevents a runaway script from creating thousands of objects and degrading API server performance. Count quotas are cheap insurance and should be included even when CPU and memory are the main concern.
Troubleshooting Kubernetes ResourceQuotas
The classic error is Forbidden: exceeded quota: team-quota, requested: requests.cpu=1, used: requests.cpu=4, limited: requests.cpu=4. Read it literally: the namespace has used its full budget, and the new pod needs one more CPU. The fixes are to delete unused pods, reduce requests on existing workloads, or raise the quota after a capacity review. Do not raise a quota reflexively, because the quota is doing its job when it blocks an over-budget deployment.
If a pod is rejected even though the numbers look fine, check for a LimitRange applying a default that pushes the pod over the limit, and check whether the quota counts limits as well as requests. A pod with a high limit and a low request can pass the request quota and fail the limit quota. Use kubectl describe quota to see exactly which resource is exhausted, because guessing between CPU, memory, and object counts wastes time.
For related cluster controls, see our guides to Kubernetes resource requests and limits and PodDisruptionBudgets. The official reference is the Kubernetes ResourceQuotas documentation.
Conclusion
Kubernetes ResourceQuotas turn “please be careful” into an enforced budget. Pair a quota with a LimitRange, set defaults so every pod counts, monitor usage with describe quota, and treat a quota rejection as a capacity conversation, not a bug. Teams that share a cluster will get predictable performance, and platform engineers will spend less time firefighting a single namespace that ate the cluster.