This error occurs when creating resources that would exceed namespace ResourceQuota limits. Fix it by reducing resource requests, deleting unused resources, or requesting a quota increase from your cluster administrator.
The "exceeded quota" error indicates that creating the requested resource would cause the namespace to exceed its ResourceQuota limits. ResourceQuotas in Kubernetes constrain the total amount of resources (CPU, memory, storage, object counts) that can be consumed within a namespace. When you try to create a Pod, PVC, or other resource, the quota controller calculates whether the new resource's requirements plus existing usage would exceed the quota's hard limits. If so, the API server rejects the request with HTTP 403 Forbidden. This is a namespace-level constraint—existing pods continue running, but new resource creation is blocked until usage drops below the quota or the quota is increased.
View quota and current usage:
# View detailed quota and usage
kubectl describe resourcequota -n <namespace>
# Get specific quota in YAML format
kubectl get resourcequota <quota-name> -n <namespace> -o yamlOutput shows:
- spec.hard: The quota limits
- status.used: Current consumption
- status.hard: Enforced limits
Compare used vs hard to identify which resource is exceeded.
Identify which pods consume the most resources:
# Sort pods by CPU usage
kubectl top pods -n <namespace> --sort-by=cpu
# Sort pods by memory usage
kubectl top pods -n <namespace> --sort-by=memory
# View resource requests for all pods
kubectl get pods -n <namespace> -o custom-columns=\
'NAME:.metadata.name,CPU_REQ:.spec.containers[*].resources.requests.cpu,MEM_REQ:.spec.containers[*].resources.requests.memory'Identify candidates for deletion or resource reduction.
Lower the resource requests to fit within quota:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
template:
spec:
containers:
- name: app
image: my-image
resources:
requests:
cpu: "100m" # Reduced from 500m
memory: "128Mi" # Reduced from 512Mi
limits:
cpu: "200m"
memory: "256Mi"Apply and verify:
kubectl apply -f deployment.yaml
kubectl get pods -n <namespace>Free up quota by removing unused resources:
# Delete unused pods
kubectl delete pod <pod-name> -n <namespace>
# Delete pods by label
kubectl delete pods -l app=unused -n <namespace>
# Delete unused PersistentVolumeClaims
kubectl delete pvc <pvc-name> -n <namespace>
# Force delete stuck pods
kubectl delete pod <pod-name> -n <namespace> --grace-period=0 --forceWait 15-30 seconds for quota controller to sync freed resources.
If legitimate workload growth requires more resources:
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
namespace: <namespace>
spec:
hard:
requests.cpu: "8" # Increased from 4
requests.memory: "16Gi" # Increased from 8Gi
limits.cpu: "12"
limits.memory: "24Gi"
pods: "20" # Increased from 10Admin applies the updated quota:
kubectl apply -f quota.yaml
kubectl describe resourcequota -n <namespace>Prevent future issues by setting default resource values:
apiVersion: v1
kind: LimitRange
metadata:
name: default-limits
namespace: <namespace>
spec:
limits:
- type: Container
default:
cpu: "200m"
memory: "256Mi"
defaultRequest:
cpu: "100m"
memory: "128Mi"
max:
cpu: "1000m"
memory: "1Gi"
min:
cpu: "50m"
memory: "64Mi"Apply:
kubectl apply -f limitrange.yamlNew pods without explicit resources will receive these defaults.
Quota Scopes: ResourceQuotas can be scoped to specific Pod priority classes:
scopeSelector:
matchExpressions:
- scopeName: PriorityClass
operator: In
values: ["high-priority"]Available Scopes:
- BestEffort: Pods with no resource limits
- NotBestEffort: Pods with at least one resource limit
- Terminating / NotTerminating: Based on activeDeadlineSeconds
- PriorityClass: Based on pod priority
Best Practices:
1. Always pair ResourceQuota + LimitRange together
2. Use PriorityClass scopes for tiered quotas
3. Monitor quota usage regularly
4. Set quotas conservatively to prevent cluster overcommit
5. Document quota limits for development teams
No subnets found for EKS cluster
How to fix "eks subnet not found" in Kubernetes
unable to compute replica count
How to fix "unable to compute replica count" in Kubernetes HPA
error: context not found
How to fix "error: context not found" in Kubernetes
default backend - 404
How to fix "default backend - 404" in Kubernetes Ingress
serviceaccount cannot list resource
How to fix "serviceaccount cannot list resource" in Kubernetes