Skip to content

Commit bf5ad71

Browse files
committed
Improvement for LimitRange Documentation.
1 parent e1d4e0f commit bf5ad71

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

content/en/docs/concepts/policy/limit-range.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ weight: 10
1111

1212
<!-- overview -->
1313

14-
By default, containers run with unbounded [compute resources](/docs/concepts/configuration/manage-resources-containers/) on a Kubernetes cluster.
14+
By default, containers run with unbounded
15+
[compute resources](/docs/concepts/configuration/manage-resources-containers/) on a Kubernetes cluster.
1516
Using Kubernetes [resource quotas](/docs/concepts/policy/resource-quotas/),
1617
administrators (also termed _cluster operators_) can restrict consumption and creation
1718
of cluster resources (such as CPU time, memory, and persistent storage) within a specified
1819
{{< glossary_tooltip text="namespace" term_id="namespace" >}}.
19-
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.
2023

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.
2226

2327
<!-- body -->
2428

@@ -29,7 +33,6 @@ A _LimitRange_ provides constraints that can:
2933
- Enforce a ratio between request and limit for a resource in a namespace.
3034
- Set default request/limit for compute resources in a namespace and automatically inject them to Containers at runtime.
3135

32-
3336
A LimitRange is enforced in a particular namespace when there is a
3437
LimitRange object in that namespace.
3538

@@ -40,43 +43,49 @@ The name of a LimitRange object must be a valid
4043

4144
- The administrator creates a LimitRange in a namespace.
4245
- 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.
5355

5456
## LimitRange and admission checks for Pods
5557

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.
5761

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.
69+
{{< /note >}}
5970

6071
{{% code_sample file="concepts/policy/limit-range/problematic-limit-range.yaml" %}}
6172

62-
6373
along with a Pod that declares a CPU resource request of `700m`, but not a limit:
6474

6575
{{% code_sample file="concepts/policy/limit-range/example-conflict-with-limitrange-cpu.yaml" %}}
6676

67-
6877
then that Pod will not be scheduled, failing with an error similar to:
6978
```
7079
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
7180
```
7281

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:
7483

7584
{{% code_sample file="concepts/policy/limit-range/example-no-conflict-with-limitrange-cpu.yaml" %}}
7685

7786
## Example resource constraints
7887

79-
Examples of policies that could be created using `LimitRange` are:
88+
Examples of policies that could be created using LimitRange are:
8089

8190
- 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.
8291
- 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:
97106
- [how to configure minimum and maximum Storage consumption per namespace](/docs/tasks/administer-cluster/limit-storage-consumption/#limitrange-to-limit-requests-for-storage).
98107
- a [detailed example on configuring quota per namespace](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/).
99108

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

Comments
 (0)