You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within a namespace, a {{< glossary_tooltip text="Pod" term_id="Pod" >}} can consume as much CPU and memory as is allowed by the ResourceQuotas that apply to that namespace. As a cluster operator, or as a namespace-level administrator, you might also be concerned about making sure that a single object cannot monopolize all available resources within a namespace.
20
+
Within a namespace, a {{< glossary_tooltip text="Pod" term_id="Pod" >}} can consume as much CPU and memory as is allowed by the ResourceQuotas that apply to that namespace.
21
+
As a cluster operator, or as a namespace-level administrator, you might also be concerned
22
+
about making sure that a single object cannot monopolize all available resources within a namespace.
20
23
21
-
A LimitRange is a policy to constrain the resource allocations (limits and requests) that you can specify for each applicable object kind (such as Pod or {{< glossary_tooltip text="PersistentVolumeClaim" term_id="persistent-volume-claim" >}}) in a namespace.
24
+
A LimitRange is a policy to constrain the resource allocations (limits and requests) that you can specify for
25
+
each applicable object kind (such as Pod or {{< glossary_tooltip text="PersistentVolumeClaim" term_id="persistent-volume-claim" >}}) in a namespace.
22
26
23
27
<!-- body -->
24
28
@@ -29,7 +33,6 @@ A _LimitRange_ provides constraints that can:
29
33
- Enforce a ratio between request and limit for a resource in a namespace.
30
34
- Set default request/limit for compute resources in a namespace and automatically inject them to Containers at runtime.
31
35
32
-
33
36
A LimitRange is enforced in a particular namespace when there is a
34
37
LimitRange object in that namespace.
35
38
@@ -40,43 +43,49 @@ The name of a LimitRange object must be a valid
40
43
41
44
- The administrator creates a LimitRange in a namespace.
42
45
- Users create (or try to create) objects in that namespace, such as Pods or PersistentVolumeClaims.
43
-
- First, the `LimitRange` admission controller applies default request and limit values for all Pods (and their containers) that do not set compute resource requirements.
44
-
- Second, the `LimitRange` tracks usage to ensure it does not exceed resource minimum, maximum and ratio defined in any `LimitRange` present in the namespace.
45
-
- If you attempt to create or update an object (Pod or PersistentVolumeClaim) that violates a `LimitRange` constraint, your request to the API server will fail with an HTTP status code `403 Forbidden` and a message explaining the constraint that has been violated.
46
-
- If you add a `LimitRange` in a namespace that applies to compute-related resources such as
47
-
`cpu` and `memory`, you must specify
48
-
requests or limits for those values. Otherwise, the system may reject Pod creation.
49
-
-`LimitRange` validations occur only at Pod admission stage, not on running Pods.
50
-
If you add or modify a LimitRange, the Pods that already exist in that namespace
51
-
continue unchanged.
52
-
- If two or more `LimitRange` objects exist in the namespace, it is not deterministic which default value will be applied.
46
+
- First, the LimitRange admission controller applies default request and limit values for all Pods (and their containers) that do not set compute resource requirements.
47
+
- Second, the LimitRange tracks usage to ensure it does not exceed resource minimum, maximum and ratio defined in any LimitRange present in the namespace.
48
+
- If you attempt to create or update an object (Pod or PersistentVolumeClaim) that violates a LimitRange constraint,
49
+
your request to the API server will fail with an HTTP status code `403 Forbidden` and a message explaining the constraint that has been violated.
50
+
- If you add a LimitRange in a namespace that applies to compute-related resources such as `cpu` and `memory`, you must specify
51
+
requests or limits for those values. Otherwise, the system may reject Pod creation.
52
+
- LimitRange validations occur only at Pod admission stage, not on running Pods.
53
+
If you add or modify a LimitRange, the Pods that already exist in that namespace continue unchanged.
54
+
- If two or more LimitRange objects exist in the namespace, it is not deterministic which default value will be applied.
53
55
54
56
## LimitRange and admission checks for Pods
55
57
56
-
A `LimitRange` does **not** check the consistency of the default values it applies. This means that a default value for the _limit_ that is set by `LimitRange` may be less than the _request_ value specified for the container in the spec that a client submits to the API server. If that happens, the final Pod will not be schedulable.
58
+
A LimitRange does **not** check the consistency of the default values it applies. This means that a default value for
59
+
the _limit_ that is set by LimitRange may be less than the _request_ value specified for the container in the spec
60
+
that a client submits to the API server. If that happens, the final Pod will not be schedulable.
57
61
58
-
For example, you define a `LimitRange` with this manifest:
62
+
For example, you define a LimitRange with below manifest:
63
+
{{< note >}}
64
+
The following examples operate within the default namespace of your cluster, as the namespace
65
+
parameter is undefined and the LimitRange scope is limited to the namespace level.
66
+
This implies that any references or operations within these examples will interact with elements
67
+
within the default namespace of your cluster. You can override the operating namespace
68
+
by configuring namespace in the `metadata.namespace` field.
then that Pod will not be scheduled, failing with an error similar to:
69
78
```
70
79
Pod "example-conflict-with-limitrange-cpu" is invalid: spec.containers[0].resources.requests: Invalid value: "700m": must be less than or equal to cpu limit
71
80
```
72
81
73
-
If you set both `request` and `limit`, then that new Pod will be scheduled successfully even with the same `LimitRange` in place:
82
+
If you set both `request` and `limit`, then that new Pod will be scheduled successfully even with the same LimitRange in place:
Examples of policies that could be created using `LimitRange` are:
88
+
Examples of policies that could be created using LimitRange are:
80
89
81
90
- In a 2 node cluster with a capacity of 8 GiB RAM and 16 cores, constrain Pods in a namespace to request 100m of CPU with a max limit of 500m for CPU and request 200Mi for Memory with a max limit of 600Mi for Memory.
82
91
- Define default CPU limit and request to 150m and memory default request to 300Mi for Containers started with no cpu and memory requests in their specs.
@@ -97,5 +106,4 @@ For examples on using limits, see:
97
106
-[how to configure minimum and maximum Storage consumption per namespace](/docs/tasks/administer-cluster/limit-storage-consumption/#limitrange-to-limit-requests-for-storage).
98
107
- a [detailed example on configuring quota per namespace](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/).
99
108
100
-
Refer to the [LimitRanger design document](https://git.k8s.io/design-proposals-archive/resource-management/admission_control_limit_range.md) for context and historical information.
101
-
109
+
Refer to the [LimitRanger design document](https://git.k8s.io/design-proposals-archive/resource-management/admission_control_limit_range.md) for context and historical information.
0 commit comments