Namespaces, ResourceQuotas and LimitRanges
A quota caps a namespace in total, a LimitRange constrains each container, and they are enforced at different moments by different code. Watch a Pod get defaults it never asked for, get a rejection from the LimitRange rather than the quota you expected, and watch a Deployment stall at 3 of 6 replicas.
Cluster Architecture and Configuration Guide 17 of 103 Intermediate
- Kubernetes1.36.4
- Cluster4 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 35 min
The specific limits are arbitrary. Which object rejects what, and when, is not.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when a namespace needs a budget, or when a Deployment is quietly running fewer replicas than you asked for. This matters because a quota caps the namespace in total while a LimitRange constrains each container, and the two are enforced at different moments by different things.
- seeing what a namespace scopes, which resources are not namespaced, and how deletion cascades
- setting a default namespace on your context instead of typing
-non every command - applying a ResourceQuota and a LimitRange, and stating plainly what each one does
- creating a Pod with no resource flags and finding values it never asked for, then asking for far too much
- seeing a Deployment stall rather than fail at the quota, then reading the quota's
status.used
Before you start
- A working cluster and
kubectl. - The requests, limits and QoS guide. Quotas are written in terms of
requests.cpuandlimits.memory, so those need to mean something to you first. - The kubectl session guide, for the difference between namespaced and cluster-scoped resources.
-
What a namespace is, and what it is not
-
Set a default namespace instead of typing -n
-
Namespace deletion is a cascade
-
A quota and a LimitRange, and why you need both
-
Watch a Pod receive resources it never asked for
-
The rejection you get is not always the one you expected
-
A Deployment does not fail, it stalls
-
Read the totals, and clean up