In a multi-tenant platform every namespace sets limits. A LimitRange defines default and maximum values per container. A pod that wants more never arrives – the API rejects it on creation.
Symptom
kubectl -n tenant-acme run fat --image=curlimages/curl:8.22.0 --restart=Never \
--overrides='{"spec":{"containers":[{"name":"fat",
"image":"curlimages/curl:8.22.0","resources":{"limits":{"memory":"16Gi"}}}]}}'
Error from server (Forbidden): pods "fat" is forbidden: maximum memory usage
per Container is 4Gi, but limit is 16Gi
In the course the second of three counter-checks tests the LimitRange's maximum in the namespace tenant-acme.
Diagnosis
A pod without its own values shows which defaults the LimitRange fills in.
kubectl -n tenant-acme get pod plain -o jsonpath='{.spec.containers[0].resources}'
{"limits":{"cpu":"500m","memory":"512Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}
Causes
maximum memory usageThe LimitRange's maximum is exceeded
The LimitRange allows at most 4Gi per container. A limit of 16Gi violates that and admission rejects the pod immediately.
DefaultsThe same LimitRange sets defaults
Pods without values get requests and limits filled in. That prevents a quota on requests.cpu from rejecting pods without requests.
Fix
kubectl -n tenant-acme delete pod plain --now
Don't: Delete the LimitRange in the tenant namespace so a single pod gets through – then no pod has limits any more.
Running LLM platforms hands-on, Day 6: multi-tenant Kubernetes – quotas, LimitRanges, NetworkPolicies, Pod Security and RBAC.
Go to day 6 →
FAQ
What is the difference between a LimitRange and a ResourceQuota?
The LimitRange limits single containers and sets defaults, the ResourceQuota limits the sum of all pods in the namespace.
Does this apply to GPUs too?
For GPUs the quota only knows requests.nvidia.com/gpu; in the pod, request and limit must be equal.