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


- Accidental large replica counts.
- CI/CD pipelines that spawn many pods.
- Namespaces without limits or defaults.




- Compute totals:
requests.cpu,limits.memory, etc. - Object counts:
pods,configmaps,servicesto prevent sprawl. - Storage: total storage requested and number of PersistentVolumeClaims.

403 Forbidden. These checks occur before scheduling—pods violating quotas are rejected before reaching the scheduler.

- Inject defaults (
defaultanddefaultRequest) when containers omit requests/limits. - Enforce minimum and maximum per-object values (
min,max).
default: default limit values applied when a container does not specify limits.defaultRequest: default request values used when a container leaves requests empty.min/max: hard per-container or per-pod bounds.
Container, Pod, PersistentVolumeClaim. The Container type is the most common.
Example LimitRange that sets per-container min/max and defaults:

- The pod spec is submitted to the API server (e.g.,
kubectl apply, controllers). - LimitRanger (LimitRange admission controller) runs first:
- If containers omit requests/limits, LimitRange injects
defaultRequest/default. - If a request violates
min/max, the request is rejected.
- If containers omit requests/limits, LimitRange injects
- ResourceQuota admission controller runs next:
- It checks whether admitting the pod (including injected defaults) would exceed the namespace quotas.
- If it would exceed quotas, the request is rejected with
403 Forbidden.
- If both checks pass, the pod is admitted and sent to the scheduler.

- Limit pod count in development namespaces:
- Prevents a developer from scaling a
Deploymentto hundreds of replicas in a single namespace.
- Prevents a developer from scaling a
- Team budget in production multi-tenant clusters:
- Caps requests and limits so teams get fair allocation across compute and memory.
- Container defaults to ensure QoS and measurable quotas:
- Apply a LimitRange in every namespace so pods never default to
BestEffortQoS and ResourceQuota can compute totals accurately.
- Apply a LimitRange in every namespace so pods never default to
LimitRange runs before ResourceQuota in the admission pipeline. This lets LimitRange inject defaults so the ResourceQuota sees complete resource requests and can correctly enforce namespace totals.
If you set ResourceQuota but do not apply LimitRange defaults, pods without requests may end up in
BestEffort QoS and ResourceQuota cannot reliably account for them. Always apply LimitRange defaults in namespaces where you use ResourceQuota.
Four takeaways
- ResourceQuota caps total namespace consumption (compute, object counts, storage).
- LimitRange sets per-container/pod defaults and enforces min/max bounds.
- Use LimitRange and ResourceQuota together to provide reliable multi-tenant governance.
- Apply sensible defaults (LimitRange) in every namespace and set ResourceQuota values appropriate to your environment (e.g., dev vs prod).
- Kubernetes ResourceQuota docs: https://kubernetes.io/docs/concepts/policy/resource-quotas/
- Kubernetes LimitRange docs: https://kubernetes.io/docs/concepts/policy/limit-range/