Skip to content

Commit 6a8abb8

Browse files
committed
OSDOCS-6582: CLIOT-28 CPU Usage guidance
1 parent 042ea0b commit 6a8abb8

File tree

7 files changed

+1115
-1
lines changed

7 files changed

+1115
-1
lines changed

_topic_maps/_topic_map.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,8 @@ Topics:
32103210
- Name: Planning your environment according to object maximums
32113211
File: planning-your-environment-according-to-object-maximums
32123212
Distros: openshift-origin,openshift-enterprise
3213+
- Name: Compute Resource Quotas
3214+
File: compute-resource-quotas
32133215
- Name: Recommended host practices for IBM Z & IBM LinuxONE environments
32143216
File: ibm-z-recommended-host-practices
32153217
Distros: openshift-enterprise

modules/admin-limit-operations.adoc

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Module included in the following assemblies:
2+
//
3+
// ../scalability_and_performance/compute-resource-quotas.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="admin-limit-operations_{context}"]
7+
= Limit range operations
8+
9+
== Creating a limit range
10+
11+
Shown here is an example procedure to follow for creating a limit range.
12+
13+
.Procedure
14+
15+
. Create the object:
16+
+
17+
[source,terminal]
18+
----
19+
$ oc create -f <limit_range_file> -n <project>
20+
----
21+
22+
== View the limit
23+
24+
You can view any limit ranges that are defined in a project by navigating in the web console to the `Quota` page for the project. You can also use the CLI to view limit range details by performing the following steps:
25+
26+
.Procedure
27+
28+
. Get the list of limit range objects that are defined in the project. For example, a project called `demoproject`:
29+
+
30+
[source,terminal]
31+
----
32+
$ oc get limits -n demoproject
33+
----
34+
+
35+
.Example Output
36+
+
37+
[source,terminal]
38+
----
39+
NAME AGE
40+
resource-limits 6d
41+
----
42+
43+
. Describe the limit range. For example, for a limit range called `resource-limits`:
44+
+
45+
[source,terminal]
46+
----
47+
$ oc describe limits resource-limits -n demoproject
48+
----
49+
+
50+
.Example Output
51+
+
52+
[source,terminal]
53+
----
54+
Name: resource-limits
55+
Namespace: demoproject
56+
Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio
57+
---- -------- --- --- --------------- ------------- -----------------------
58+
Pod cpu 200m 2 - - -
59+
Pod memory 6Mi 1Gi - - -
60+
Container cpu 100m 2 200m 300m 10
61+
Container memory 4Mi 1Gi 100Mi 200Mi -
62+
openshift.io/Image storage - 1Gi - - -
63+
openshift.io/ImageStream openshift.io/image - 12 - - -
64+
openshift.io/ImageStream openshift.io/image-tags - 10 - - -
65+
----
66+
67+
== Deleting a limit range
68+
69+
To remove a limit range, run the following command:
70+
+
71+
[source,terminal]
72+
----
73+
$ oc delete limits <limit_name>
74+
----
75+
S

modules/admin-quota-limits.adoc

+295
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
// Module included in the following assemblies:
2+
//
3+
// ../scalability_and_performance/compute-resource-quotas.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="admin-quota-limits_{context}"]
7+
= Setting limit ranges
8+
9+
A limit range, defined by a `LimitRange` object, defines compute resource constraints at the pod, container, image, image stream, and persistent volume claim level. The limit range specifies the amount of resources that a pod, container, image, image stream, or persistent volume claim can consume.
10+
11+
All requests to create and modify resources are evaluated against each `LimitRange` object in the project. If the resource violates any of the enumerated constraints, the resource is rejected. If the resource does not set an explicit value, and if the constraint supports a default value, the default value is applied to the resource.
12+
13+
For CPU and memory limits, if you specify a maximum value but do not specify a minimum limit, the resource can consume more CPU and memory resources than the maximum value.
14+
15+
16+
ifdef::openshift-online[]
17+
[IMPORTANT]
18+
====
19+
For {product-title} Pro, the maximum pod memory is 3Gi. The minimum pod or container memory that you can specify is 100Mi.
20+
21+
For {product-title} Starter, the maximum pod memory is 1Gi. The minimum pod or container memory that you can specify is 200Mi.
22+
====
23+
endif::[]
24+
25+
.Core limit range object definition
26+
27+
[source,yaml]
28+
----
29+
apiVersion: "v1"
30+
kind: "LimitRange"
31+
metadata:
32+
name: "core-resource-limits" <1>
33+
spec:
34+
limits:
35+
- type: "Pod"
36+
max:
37+
cpu: "2" <2>
38+
memory: "1Gi" <3>
39+
min:
40+
cpu: "200m" <4>
41+
memory: "6Mi" <5>
42+
- type: "Container"
43+
max:
44+
cpu: "2" <6>
45+
memory: "1Gi" <7>
46+
min:
47+
cpu: "100m" <8>
48+
memory: "4Mi" <9>
49+
default:
50+
cpu: "300m" <10>
51+
memory: "200Mi" <11>
52+
defaultRequest:
53+
cpu: "200m" <12>
54+
memory: "100Mi" <13>
55+
maxLimitRequestRatio:
56+
cpu: "10" <14>
57+
----
58+
<1> The name of the limit range object.
59+
<2> The maximum amount of CPU that a pod can request on a node across all containers.
60+
<3> The maximum amount of memory that a pod can request on a node across all containers.
61+
<4> The minimum amount of CPU that a pod can request on a node across all containers. If you do not set a `min` value or you set `min` to `0`, the result is no limit and the pod can consume more than the `max` CPU value.
62+
<5> The minimum amount of memory that a pod can request on a node across all containers. If you do not set a `min` value or you set `min` to `0`, the result is no limit and the pod can consume more than the `max` memory value.
63+
<6> The maximum amount of CPU that a single container in a pod can request.
64+
<7> The maximum amount of memory that a single container in a pod can request.
65+
<8> The minimum amount of CPU that a single container in a pod can request. If you do not set a `min` value or you set `min` to `0`, the result is no limit and the pod can consume more than the `max` CPU value.
66+
<9> The minimum amount of memory that a single container in a pod can request. If you do not set a `min` value or you set `min` to `0`, the result is no limit and the pod can consume more than the `max` memory value.
67+
<10> The default CPU limit for a container if you do not specify a limit in the pod specification.
68+
<11> The default memory limit for a container if you do not specify a limit in the pod specification.
69+
<12> The default CPU request for a container if you do not specify a request in the pod specification.
70+
<13> The default memory request for a container if you do not specify a request in the pod specification.
71+
<14> The maximum limit-to-request ratio for a container.
72+
73+
74+
.{product-title} Limit range object definition
75+
76+
[source,yaml]
77+
----
78+
apiVersion: "v1"
79+
kind: "LimitRange"
80+
metadata:
81+
name: "openshift-resource-limits"
82+
spec:
83+
limits:
84+
- type: openshift.io/Image
85+
max:
86+
storage: 1Gi <1>
87+
- type: openshift.io/ImageStream
88+
max:
89+
openshift.io/image-tags: 20 <2>
90+
openshift.io/images: 30 <3>
91+
- type: "Pod"
92+
max:
93+
cpu: "2" <4>
94+
memory: "1Gi" <5>
95+
ephemeral-storage: "1Gi" <6>
96+
min:
97+
cpu: "1" <7>
98+
memory: "1Gi" <8>
99+
----
100+
<1> The maximum size of an image that can be pushed to an internal registry.
101+
<2> The maximum number of unique image tags as defined in the specification for the image stream.
102+
<3> The maximum number of unique image references as defined in the specification for the image stream status.
103+
<4> The maximum amount of CPU that a pod can request on a node across all containers.
104+
<5> The maximum amount of memory that a pod can request on a node across all containers.
105+
<6> The maximum amount of ephemeral storage that a pod can request on a node across all containers.
106+
<7> The minimum amount of CPU that a pod can request on a node across all containers. See the Supported Constraints table for important information.
107+
<8> The minimum amount of memory that a pod can request on a node across all containers. If you do not set a `min` value or you set `min` to `0`, the result` is no limit and the pod can consume more than the `max` memory value.
108+
109+
You can specify both core and {product-title} resources in one limit range object.
110+
111+
== Container limits
112+
113+
*Supported Resources:*
114+
115+
* CPU
116+
* Memory
117+
118+
.Supported Constraints
119+
120+
Per container, the following must hold true if specified:
121+
122+
*Container*
123+
[cols="3a,8a",options="header"]
124+
|===
125+
126+
|Constraint |Behavior
127+
128+
|`Min`
129+
|`Min[<resource>]` less than or equal to `container.resources.requests[<resource>]` (required) less than or equal to `container/resources.limits[<resource>]` (optional)
130+
131+
If the configuration defines a `min` CPU, the request value must be greater than the CPU value. If you do not set a `min` value or you set `min` to `0`, the result is no limit and the pod can consume more of the resource than the `max` value.
132+
133+
|`Max`
134+
|`container.resources.limits[<resource>]` (required) less than or equal to `Max[<resource>]`
135+
136+
If the configuration defines a `max` CPU, you do not need to define a CPU request value. However, you must set a limit that satisfies the maximum CPU constraint that is specified in the limit range.
137+
138+
|`MaxLimitRequestRatio`
139+
|`MaxLimitRequestRatio[<resource>]` less than or equal to (`container.resources.limits[<resource>]` / `container.resources.requests[<resource>]`)
140+
141+
If the limit range defines a `maxLimitRequestRatio` constraint, any new containers must have both a `request` and a `limit` value. Additionally, {product-title} calculates a limit-to-request ratio by dividing the `limit` by the `request`. The result should be an integer greater than 1.
142+
143+
For example, if a container has `cpu: 500` in the `limit` value, and `cpu: 100` in the `request` value, the limit-to-request ratio for `cpu` is `5`. This ratio must be less than or equal to the `maxLimitRequestRatio`.
144+
|===
145+
146+
*Supported Defaults:*
147+
148+
`Default[<resource>]`:: Defaults `container.resources.limit[<resource>]` to specified value if none.
149+
`Default Requests[<resource>]`:: Defaults `container.resources.requests[<resource>]` to specified value if none.
150+
151+
152+
== Pod limits
153+
154+
*Supported Resources:*
155+
156+
* CPU
157+
* Memory
158+
159+
*Supported Constraints:*
160+
161+
Across all containers in a pod, the following must hold true:
162+
163+
.Pod
164+
[cols="3a,8a",options="header"]
165+
|===
166+
167+
|Constraint |Enforced Behavior
168+
169+
|`Min`
170+
|`Min[<resource>]` less than or equal to `container.resources.requests[<resource>]` (required) less than or equal to `container.resources.limits[<resource>]`. If you do not set a `min` value or you set `min` to `0`, the result is no limit and the pod can consume more of the resource than the `max` value.
171+
172+
|`Max`
173+
|`container.resources.limits[<resource>]` (required) less than or equal to `Max[<resource>]`.
174+
175+
|`MaxLimitRequestRatio`
176+
|`MaxLimitRequestRatio[<resource>]` less than or equal to (`container.resources.limits[<resource>]` / `container.resources.requests[<resource>]`).
177+
178+
|===
179+
180+
== Image limits
181+
182+
Supported Resources:
183+
184+
* Storage
185+
186+
Resource type name:
187+
188+
- `openshift.io/Image`
189+
190+
Per image, the following must hold true if specified:
191+
192+
.Image
193+
[cols="3a,8a",options="header"]
194+
|===
195+
|Constraint |Behavior
196+
197+
|`Max`
198+
|`image.dockerimagemetadata.size` less than or equal to `Max[<resource>]`
199+
|===
200+
201+
[NOTE]
202+
====
203+
To prevent blobs that exceed the limit from being uploaded to the registry, the registry must be configured to enforce quota. The `REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ENFORCEQUOTA` environment variable must be set to `true`. By default, the environment variable is set to `true` for new deployments.
204+
====
205+
206+
== Image stream limits
207+
208+
*Supported Resources:*
209+
210+
* `openshift.io/image-tags`
211+
* `openshift.io/images`
212+
213+
*Resource type name:*
214+
215+
- `openshift.io/ImageStream`
216+
217+
Per image stream, the following must hold true if specified:
218+
219+
.ImageStream
220+
[cols="3a,8a",options="header"]
221+
|===
222+
|Constraint |Behavior
223+
224+
|`Max[openshift.io/image-tags]`
225+
|`length( uniqueimagetags( imagestream.spec.tags ) )` less than or equal to `Max[openshift.io/image-tags]`
226+
227+
`uniqueimagetags` returns unique references to images of given spec tags.
228+
229+
|`Max[openshift.io/images]`
230+
|`length( uniqueimages( imagestream.status.tags ) )` less than or equal to `Max[openshift.io/images]`
231+
232+
`uniqueimages` returns unique image names found in status tags. The name is equal to the digest for the image.
233+
234+
|===
235+
236+
== Counting of image references
237+
238+
The `openshift.io/image-tags` resource represents unique stream limits. Possible references are an `ImageStreamTag`, an `ImageStreamImage`, or a `DockerImage`. Tags can be created by using the `oc tag` and `oc import-image` commands or by using image streams. No distinction is made between internal and external references. However, each unique reference that is tagged in an image stream specification is counted just once. It does not restrict pushes to an internal container image registry in any way, but is useful for tag restriction.
239+
240+
The `openshift.io/images` resource represents unique image names that are recorded in image stream status. It helps to restrict several images that can be pushed to the internal registry. Internal and external references are not distinguished.
241+
242+
243+
== PersistentVolumeClaim limits
244+
245+
*Supported Resources:*
246+
247+
* Storage
248+
249+
*Supported Constraints:*
250+
251+
Across all persistent volume claims in a project, the following must hold true:
252+
253+
.Pod
254+
[cols="3a,8a",options="header"]
255+
|===
256+
257+
|Constraint |Enforced Behavior
258+
259+
|`Min`
260+
|Min[<resource>] +<=+ claim.spec.resources.requests[<resource>] (required)
261+
262+
|`Max`
263+
|claim.spec.resources.requests[<resource>] (required) +<=+ Max[<resource>]
264+
|===
265+
266+
[[limit-range-obj-def]]
267+
268+
.Limit Range Object Definition
269+
270+
[source,json]
271+
----
272+
{
273+
"apiVersion": "v1",
274+
"kind": "LimitRange",
275+
"metadata": {
276+
"name": "pvcs" <1>
277+
},
278+
"spec": {
279+
"limits": [{
280+
"type": "PersistentVolumeClaim",
281+
"min": {
282+
"storage": "2Gi" <2>
283+
},
284+
"max": {
285+
"storage": "50Gi" <3>
286+
}
287+
}
288+
]
289+
}
290+
}
291+
----
292+
<1> The name of the limit range object.
293+
<2> The minimum amount of storage that can be requested in a persistent volume claim.
294+
<3> The maximum amount of storage that can be requested in a persistent volume claim.
295+

0 commit comments

Comments
 (0)