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 CLI to install the cluster Resource Override Operator to help control overcommit in your cluster.
By default, the installation process creates a cluster Resource Override Operator pod on a worker node in the clusterresourceoverride-operator
namespace. You can move this pod to another node, such as an infrastructure node, as needed. Infrastructure nodes are not counted toward the total number of subscriptions that are required to run the environment. For more information, see "Moving the cluster Resource Override Operator pods".
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 1 Gi of RAM at 100 percent is equal to 1 CPU core. This is processed before 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.
By default, the installation process creates a cluster Resource Override Operator pod on a worker node in the clusterresourceoverride-operator
namespace. You can move this pod to another node, such as an infrastructure node, as needed. Infrastructure nodes are not counted toward the total number of subscriptions that are required to run the environment. For more information, see "Moving the cluster Resource Override Operator pods".
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.18"
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 1 Gi of RAM at 100 percent is equal to 1 CPU core. This is processed before 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.
By default, the installation process creates two cluster Resource Override pods on the control plane nodes in the clusterresourceoverride-operator
namespace. You can move these pods to other nodes, such as infrastructure nodes, as needed. Infrastructure nodes are not counted toward the total number of subscriptions that are required to run the environment. For more information, see "Moving the cluster Resource Override Operator pods".
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 before 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. |
Moving the cluster Resource Override Operator pods
By default, the cluster Resource Override Operator installation process creates an Operator pod and two cluster Resource Override pods on nodes in the clusterresourceoverride-operator
namespace. You can move these pods to other nodes, such as infrastructure nodes, as needed.
You can create and use infrastructure nodes to host only infrastructure components, such as the default router, the integrated container image registry, and the components for cluster metrics and monitoring. These infrastructure nodes are not counted toward the total number of subscriptions that are required to run the environment. For more information about infrastructure nodes, see "Creating infrastructure machine sets".
The following examples shows the cluster Resource Override pods are deployed to control plane nodes and the cluster Resource Override Operator pod is deployed to a worker node.
Example cluster Resource Override pods
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
clusterresourceoverride-786b8c898c-9wrdq 1/1 Running 0 23s 10.128.2.32 ip-10-0-14-183.us-west-2.compute.internal <none> <none>
clusterresourceoverride-786b8c898c-vn2lf 1/1 Running 0 26s 10.130.2.10 ip-10-0-20-140.us-west-2.compute.internal <none> <none>
clusterresourceoverride-operator-6b8b8b656b-lvr62 1/1 Running 0 56m 10.131.0.33 ip-10-0-2-39.us-west-2.compute.internal <none> <none>
Example node list
NAME STATUS ROLES AGE VERSION
ip-10-0-14-183.us-west-2.compute.internal Ready control-plane,master 65m v1.31.3
ip-10-0-2-39.us-west-2.compute.internal Ready worker 58m v1.31.3
ip-10-0-20-140.us-west-2.compute.internal Ready control-plane,master 65m v1.31.3
ip-10-0-23-244.us-west-2.compute.internal Ready infra 55m v1.31.3
ip-10-0-77-153.us-west-2.compute.internal Ready control-plane,master 65m v1.31.3
ip-10-0-99-108.us-west-2.compute.internal Ready worker 24m v1.31.3
ip-10-0-24-233.us-west-2.compute.internal Ready infra 55m v1.31.3
ip-10-0-88-109.us-west-2.compute.internal Ready worker 24m v1.31.3
ip-10-0-67-453.us-west-2.compute.internal Ready infra 55m v1.31.3
Procedure
-
Move the cluster Resource Override Operator pod by adding a node selector to the Subscription
custom resource (CR) for the cluster Resource Override Operator.
-
Edit the CR:
$ oc edit -n clusterresourceoverride-operator subscriptions.operators.coreos.com clusterresourceoverride
-
Add a node selector to match the node role label on the node where you want to install the cluster Resource Override Operator pod:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: clusterresourceoverride
namespace: clusterresourceoverride-operator
# ...
spec:
config:
nodeSelector:
node-role.kubernetes.io/infra: "" (1)
# ...
1 |
Specify the role of the node where you want to deploy the cluster Resource Override Operator pod. |
|
If the infra node uses taints, you need to add a toleration to the Subscription CR.
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: clusterresourceoverride
namespace: clusterresourceoverride-operator
# ...
spec:
config:
nodeSelector:
node-role.kubernetes.io/infra: ""
tolerations: (1)
- key: "node-role.kubernetes.io/infra"
operator: "Exists"
effect: "NoSchedule"
1 |
Specifies a toleration for a taint on the infra node. |
|
-
Move the cluster Resource Override pods by adding a node selector to the clusterResourceOverride
custom resource (CR):
-
Edit the CR:
$ oc edit clusterResourceOverride cluster -n clusterresourceoverride-operator
-
Add a node selector to match the node role label on the infra node:
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
name: cluster
resourceVersion: "37952"
spec:
podResourceOverride:
spec:
cpuRequestToLimitPercent: 25
limitCPUToMemoryPercent: 200
memoryRequestToLimitPercent: 50
deploymentOverrides:
replicas: 1 (1)
nodeSelector:
node-role.kubernetes.io/infra: "" (2)
# ...
1 |
Optional: Specify the number of cluster Resource Override pods to deploy. The default is 2 . Only one pod is allowed per node. |
2 |
Optional: Specify the role of the node where you want to deploy the cluster Resource Override pods. |
|
If the infra node uses taints, you need to add a toleration to the clusterResourceOverride CR.
apiVersion: operator.autoscaling.openshift.io/v1
kind: clusterResourceOverride
metadata:
name: cluster
# ...
spec:
podResourceOverride:
spec:
memoryRequestToLimitPercent: 50
cpuRequestToLimitPercent: 25
limitCPUToMemoryPercent: 200
deploymentOverrides:
replicas: 3
nodeSelector:
node-role.kubernetes.io/worker: ""
tolerations: (1)
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
1 |
Specifies a toleration for a taint on the infra node. |
|