- Describe the purpose of ResourceQuota and LimitRange.
- Set namespace-level limits using ResourceQuota.
- Apply default container limits using LimitRange.
- Explain how both interact during pod admission.





- The sum of all container CPU requests in the namespace cannot exceed 4 cores.
- The sum of all memory requests cannot exceed 8Gi.
- The total number of pods in the namespace cannot exceed 10.
- Compute:
requests.cpu,requests.memory,limits.cpu,limits.memory. - Object counts:
count/pods,count/configmaps,count/services— prevents object sprawl. - Storage:
requests.storage, number of PersistentVolumeClaims, and volume counts.


- Inject defaults (
defaultRequest/default) when containers omit requests or limits. - Enforce minimum (
min) and maximum (max) bounds for individual containers or pods.
requests.* and limits.*, ensuring containers specify these fields is important for accurate quota enforcement. LimitRange automates that by filling in defaults or rejecting pods that fall outside acceptable per-object ranges.
LimitRange applies to types such as Container, Pod, and PersistentVolumeClaim (Container is most commonly used).

- Ensures containers specify at least
50mCPU and64Mimemory. - Caps containers at
1CPU and1Gi. - Injects default request values when not provided (so pods are not BestEffort).

- Pod submitted to the API server (via kubectl, controller, etc.).
- LimitRange admission controller intercepts:
- Injects defaults if containers omit requests/limits (
defaultRequest/default). - Validates that per-object
min/maxconstraints are satisfied; rejects if not.
- Injects defaults if containers omit requests/limits (
- ResourceQuota admission controller evaluates whether admitting this pod would exceed namespace-wide budgets by summing requests/limits with current usage; rejects if quota would be exceeded.
- If both checks pass, the pod is admitted and sent to the scheduler for placement.

Practical examples
limit-pod-count(ResourceQuota) — stops a namespace creating more than 10 pods. Useful for development namespaces.team-budget(ResourceQuota) — caps CPU and memory for a team namespace in multi-tenant clusters.container-defaults(LimitRange) — injects default requests so containers are not BestEffort and ResourceQuota can account for them.
Best practice: Apply a LimitRange that injects reasonable default requests to every namespace, and then use ResourceQuota to cap aggregate consumption per namespace. This prevents BestEffort QoS, enables quota accounting, and reduces noisy-neighbor incidents.
- ResourceQuota caps total namespace consumption (aggregate budget).
- LimitRange sets defaults and enforces min/max per container or pod.
- Use both together: LimitRange ensures objects have requests/limits so ResourceQuota can account for them accurately.
- Admission order matters: LimitRange defaulting/validation runs before ResourceQuota’s quota checks, and both run before scheduling.
- Kubernetes ResourceQuota: https://kubernetes.io/docs/concepts/policy/resource-quotas/
- Kubernetes LimitRange: https://kubernetes.io/docs/concepts/policy/limit-range/
- Kubernetes admission controllers overview: https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/