The cluster Resource Override Operator is an admission webhook that allows you to control the level of overcommit and manage
container density across all the nodes in your cluster. The Operator controls how nodes in specific projects can exceed defined memory and CPU limits.
The Operator modifies the ratio between the requests and limits that are set on developer containers. In conjunction with a per-project limit range that specifies limits and defaults, you can achieve the desired level of overcommit.
You must install the cluster Resource Override Operator by using the OpenShift Container Platform console or CLI as shown in the following sections. After you deploy the cluster Resource Override Operator, the Operator modifies all new pods in specific namespaces. The Operator does not edit pods that existed before you deployed the Operator.
During the installation, you create a clusterResourceOverride
custom resource (CR), where you set the level of overcommit, as shown in the
following example:
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
name: cluster (1)
spec:
podResourceOverride:
spec:
memoryRequestToLimitPercent: 50 (2)
cpuRequestToLimitPercent: 25 (3)
limitCPUToMemoryPercent: 200 (4)
# ...
1 |
The name must be cluster . |
2 |
Optional. If a container memory limit has been specified or defaulted, the memory request is overridden to this percentage of the limit, between 1-100. The default is 50. |
3 |
Optional. If a container CPU limit has been specified or defaulted, the CPU request is overridden to this percentage of the limit, between 1-100. The default is 25. |
4 |
Optional. If a container memory limit has been specified or defaulted, the CPU limit is overridden to a percentage of the memory limit, if specified. Scaling 1Gi of RAM at 100 percent is equal to 1 CPU core. This is processed prior to overriding the CPU request (if configured). The default is 200. |
|
The cluster Resource Override Operator overrides have no effect if limits have not
been set on containers. Create a LimitRange object with default limits per individual project
or configure limits in Pod specs for the overrides to apply.
|
When configured, you can enable overrides on a per-project basis by applying the following label to the Namespace
object for each project where you want the overrides to apply. For example, you can configure override so that infrastructure components are not subject to the overrides.
apiVersion: v1
kind: Namespace
metadata:
# ...
labels:
clusterresourceoverrides.admission.autoscaling.openshift.io/enabled: "true"
# ...
The Operator watches for the clusterResourceOverride
CR and ensures that the clusterResourceOverride
admission webhook is installed into the same namespace as the operator.
For example, a pod has the following resources limits:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: my-namespace
# ...
spec:
containers:
- name: hello-openshift
image: openshift/hello-openshift
resources:
limits:
memory: "512Mi"
cpu: "2000m"
# ...
The cluster Resource Override Operator intercepts the original pod request, then overrides the resources according to the configuration set in the clusterResourceOverride
object.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: my-namespace
# ...
spec:
containers:
- image: openshift/hello-openshift
name: hello-openshift
resources:
limits:
cpu: "1" (1)
memory: 512Mi
requests:
cpu: 250m (2)
memory: 256Mi
# ...
1 |
The CPU limit has been overridden to 1 because the limitCPUToMemoryPercent parameter is set to 200 in the clusterResourceOverride object. As such, 200% of the memory limit, 512Mi in CPU terms, is 1 CPU core. |
2 |
The CPU request is now 250m because the cpuRequestToLimit is set to 25 in the clusterResourceOverride object. As such, 25% of the 1 CPU core is 250m. |
Installing the cluster Resource Override Operator using the web console
You can use the OpenShift Container Platform web console to install the cluster Resource Override Operator to help control overcommit in your cluster.
Procedure
To install the cluster Resource Override Operator using the OpenShift Container Platform web console:
-
In the OpenShift Container Platform web console, navigate to Home → Projects
-
Click Create Project.
-
Specify clusterresourceoverride-operator
as the name of the project.
-
Click Create.
-
Navigate to Operators → OperatorHub.
-
Choose clusterResourceOverride Operator from the list of available Operators and click Install.
-
On the Install Operator page, make sure A specific Namespace on the cluster is selected for Installation Mode.
-
Make sure clusterresourceoverride-operator is selected for Installed Namespace.
-
Select an Update Channel and Approval Strategy.
-
Click Install.
-
On the Installed Operators page, click clusterResourceOverride.
-
On the clusterResourceOverride Operator details page, click Create clusterResourceOverride.
-
On the Create clusterResourceOverride page, click YAML view and edit the YAML template to set the overcommit values as needed:
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
name: cluster (1)
spec:
podResourceOverride:
spec:
memoryRequestToLimitPercent: 50 (2)
cpuRequestToLimitPercent: 25 (3)
limitCPUToMemoryPercent: 200 (4)
# ...
1 |
The name must be cluster . |
2 |
Optional. Specify the percentage to override the container memory limit, if used, between 1-100. The default is 50. |
3 |
Optional. Specify the percentage to override the container CPU limit, if used, between 1-100. The default is 25. |
4 |
Optional. Specify the percentage to override the container memory limit, if used. Scaling 1Gi of RAM at 100 percent is equal to 1 CPU core. This is processed prior to overriding the CPU request, if configured. The default is 200. |
-
Click Create.
-
Check the current state of the admission webhook by checking the status of the cluster custom resource:
-
On the clusterResourceOverride Operator page, click cluster.
-
On the clusterResourceOverride Details page, click YAML. The mutatingWebhookConfigurationRef
section appears when the webhook is called.
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"operator.autoscaling.openshift.io/v1","kind":"clusterResourceOverride","metadata":{"annotations":{},"name":"cluster"},"spec":{"podResourceOverride":{"spec":{"cpuRequestToLimitPercent":25,"limitCPUToMemoryPercent":200,"memoryRequestToLimitPercent":50}}}}
creationTimestamp: "2019-12-18T22:35:02Z"
generation: 1
name: cluster
resourceVersion: "127622"
selfLink: /apis/operator.autoscaling.openshift.io/v1/clusterresourceoverrides/cluster
uid: 978fc959-1717-4bd1-97d0-ae00ee111e8d
spec:
podResourceOverride:
spec:
cpuRequestToLimitPercent: 25
limitCPUToMemoryPercent: 200
memoryRequestToLimitPercent: 50
status:
# ...
mutatingWebhookConfigurationRef: (1)
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
name: clusterresourceoverrides.admission.autoscaling.openshift.io
resourceVersion: "127621"
uid: 98b3b8ae-d5ce-462b-8ab5-a729ea8f38f3
# ...
1 |
Reference to the clusterResourceOverride admission webhook. |
Installing the cluster Resource Override Operator using the CLI
You can use the OpenShift Container Platform CLI to install the cluster Resource Override Operator to help control overcommit in your cluster.
Procedure
To install the cluster Resource Override Operator using the CLI:
-
Create a namespace for the cluster Resource Override Operator:
-
Create a Namespace
object YAML file (for example, cro-namespace.yaml
) for the cluster Resource Override Operator:
apiVersion: v1
kind: Namespace
metadata:
name: clusterresourceoverride-operator
-
Create the namespace:
$ oc create -f <file-name>.yaml
$ oc create -f cro-namespace.yaml
-
Create an Operator group:
-
Create an OperatorGroup
object YAML file (for example, cro-og.yaml) for the cluster Resource Override Operator:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: clusterresourceoverride-operator
namespace: clusterresourceoverride-operator
spec:
targetNamespaces:
- clusterresourceoverride-operator
-
Create the Operator Group:
$ oc create -f <file-name>.yaml
$ oc create -f cro-og.yaml
-
Create a subscription:
-
Create a Subscription
object YAML file (for example, cro-sub.yaml) for the cluster Resource Override Operator:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: clusterresourceoverride
namespace: clusterresourceoverride-operator
spec:
channel: "4.14"
name: clusterresourceoverride
source: redhat-operators
sourceNamespace: openshift-marketplace
-
Create the subscription:
$ oc create -f <file-name>.yaml
$ oc create -f cro-sub.yaml
-
Create a clusterResourceOverride
custom resource (CR) object in the clusterresourceoverride-operator
namespace:
-
Change to the clusterresourceoverride-operator
namespace.
$ oc project clusterresourceoverride-operator
-
Create a clusterResourceOverride
object YAML file (for example, cro-cr.yaml) for the cluster Resource Override Operator:
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
name: cluster (1)
spec:
podResourceOverride:
spec:
memoryRequestToLimitPercent: 50 (2)
cpuRequestToLimitPercent: 25 (3)
limitCPUToMemoryPercent: 200 (4)
1 |
The name must be cluster . |
2 |
Optional. Specify the percentage to override the container memory limit, if used, between 1-100. The default is 50. |
3 |
Optional. Specify the percentage to override the container CPU limit, if used, between 1-100. The default is 25. |
4 |
Optional. Specify the percentage to override the container memory limit, if used. Scaling 1Gi of RAM at 100 percent is equal to 1 CPU core. This is processed prior to overriding the CPU request, if configured. The default is 200. |
-
Create the clusterResourceOverride
object:
$ oc create -f <file-name>.yaml
$ oc create -f cro-cr.yaml
-
Verify the current state of the admission webhook by checking the status of the cluster custom resource.
$ oc get clusterresourceoverride cluster -n clusterresourceoverride-operator -o yaml
The mutatingWebhookConfigurationRef
section appears when the webhook is called.
Example output
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"operator.autoscaling.openshift.io/v1","kind":"clusterResourceOverride","metadata":{"annotations":{},"name":"cluster"},"spec":{"podResourceOverride":{"spec":{"cpuRequestToLimitPercent":25,"limitCPUToMemoryPercent":200,"memoryRequestToLimitPercent":50}}}}
creationTimestamp: "2019-12-18T22:35:02Z"
generation: 1
name: cluster
resourceVersion: "127622"
selfLink: /apis/operator.autoscaling.openshift.io/v1/clusterresourceoverrides/cluster
uid: 978fc959-1717-4bd1-97d0-ae00ee111e8d
spec:
podResourceOverride:
spec:
cpuRequestToLimitPercent: 25
limitCPUToMemoryPercent: 200
memoryRequestToLimitPercent: 50
status:
# ...
mutatingWebhookConfigurationRef: (1)
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
name: clusterresourceoverrides.admission.autoscaling.openshift.io
resourceVersion: "127621"
uid: 98b3b8ae-d5ce-462b-8ab5-a729ea8f38f3
# ...
1 |
Reference to the clusterResourceOverride admission webhook. |
The cluster Resource Override Operator requires a clusterResourceOverride
custom resource (CR)
and a label for each project where you want the Operator to control overcommit.
Procedure
To modify cluster-level overcommit:
-
Edit the clusterResourceOverride
CR:
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
name: cluster
spec:
podResourceOverride:
spec:
memoryRequestToLimitPercent: 50 (1)
cpuRequestToLimitPercent: 25 (2)
limitCPUToMemoryPercent: 200 (3)
# ...
1 |
Optional. Specify the percentage to override the container memory limit, if used, between 1-100. The default is 50. |
2 |
Optional. Specify the percentage to override the container CPU limit, if used, between 1-100. The default is 25. |
3 |
Optional. Specify the percentage to override the container memory limit, if used. Scaling 1Gi of RAM at 100 percent is equal to 1 CPU core. This is processed prior to overriding the CPU request, if configured. The default is 200. |
-
Ensure the following label has been added to the Namespace object for each project where you want the cluster Resource Override Operator to control overcommit:
apiVersion: v1
kind: Namespace
metadata:
# ...
labels:
clusterresourceoverrides.admission.autoscaling.openshift.io/enabled: "true" (1)
# ...
1 |
Add this label to each project. |