1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/nodes-cluster-limit-ranges-creating.adoc

85 lines
2.9 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/cluster/limit-ranges.adoc
:_mod-docs-content-type: PROCEDURE
[id="nodes-cluster-limit-creating_{context}"]
= Creating a Limit Range
[role="_abstract"]
You can define `LimitRange` objects to set specific resource limits for a pod, container, image, image stream, or persistent volume claim (PVC) in a specific project. A limit range allows you to restrict resource consumption in that project.
.Procedure
. Create a `LimitRange` object with your required specifications:
+
[source,yaml]
----
apiVersion: "v1"
kind: "LimitRange"
metadata:
name: "resource-limits"
spec:
limits:
- type: "Pod"
max:
cpu: "2"
memory: "1Gi"
min:
cpu: "200m"
memory: "6Mi"
- type: "Container"
max:
cpu: "2"
memory: "1Gi"
min:
cpu: "100m"
memory: "4Mi"
default:
cpu: "300m"
memory: "200Mi"
defaultRequest:
cpu: "200m"
memory: "100Mi"
maxLimitRequestRatio:
cpu: "10"
- type: openshift.io/Image
max:
storage: 1Gi
- type: openshift.io/ImageStream
max:
openshift.io/image-tags: 20
openshift.io/images: 30
- type: "PersistentVolumeClaim"
min:
storage: "2Gi"
max:
storage: "50Gi"
----
where:
+
--
`metadata.name`:: Specifies a name for the `LimitRange` object.
`spec.limit.type.Pod`:: Specifies limits for a pod, specify the minimum and maximum CPU and memory requests as needed.
`spec.limit.type.Container`:: Specifies limits for a container, specify the minimum and maximum CPU and memory requests as needed.
`spec.limit.type.default`:: For a container, specifies the default amount of CPU or memory that a container can use, if not specified in the `Pod` spec. This parameter is optional.
`spec.limit.type.defaultRequest`:: For a container, specifies the default amount of CPU or memory that a container can request, if not specified in the `Pod` spec. This parameter is optional.
`spec.limit.type.maxLimitRequestRatio`:: For a container, specifies the maximum limit-to-request ratio that can be specified in the `Pod` spec. This parameter is optional.
`spec.limit.type.openshift.io/Image`:: Specifies limits for an image object. Set the maximum size of an image that can be pushed to an {product-registry}.
`spec.limit.type.openshift.io/ImageStream`:: Specifies limits for an image stream. Set the maximum number of image tags and references that can be in the `ImageStream` object file, as needed.
`spec.limit.type.openshift.io/PersistentVolueClaim`:: Specifies limits for a persistent volume claim. Set the minimum and maximum amount of storage that can be requested.
--
. Create the object:
+
[source,terminal]
----
$ oc create -f <limit_range_file> -n <project>
----
where:
+
--
`<limit_range_file>`:: Specifies the name of the YAML file you created.
`<project>`:: Specifies the project where you want the limits to apply.
--