Drill: Check Resource Quotas and Limit Ranges¶
Goal¶
Inspect resource quotas and limit ranges in a namespace to understand resource constraints and capacity.
Setup¶
- kubectl configured with cluster access
- A namespace with resource quotas or limit ranges configured
Commands¶
List resource quotas in a namespace:
Describe a resource quota with usage details:
View the quota in YAML:
List limit ranges:
Describe a limit range with defaults:
Check current resource usage against quota:
kubectl get resourcequota -n <namespace> -o custom-columns='NAME:.metadata.name,CPU_USED:.status.used.requests\.cpu,CPU_HARD:.status.hard.requests\.cpu,MEM_USED:.status.used.requests\.memory,MEM_HARD:.status.hard.requests\.memory'
Check if a specific resource is close to quota:
List all pods with their resource requests:
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'
What to Look For¶
Usedclose toHardmeans the namespace is near capacity- LimitRange
defaultvalues are applied to containers without explicit resource specs - LimitRange
maxprevents any single container from requesting too many resources - Pods failing to create with "exceeded quota" are blocked at admission time
Common Mistakes¶
- Not setting resource requests on pods, then being surprised when defaults from LimitRange apply
- Confusing resource requests (scheduling) with limits (enforcement)
- Not checking quota when pods fail to create with vague admission errors
- Forgetting that quota applies to the sum of all pods in the namespace
Cleanup¶
No cleanup needed. These are read-only inspection commands.