Manually allocating resources for nodes
As an administrator, you can manually set system-reserved CPU and memory resources for your nodes. Setting these values ensures that your cluster is running efficiently and prevents node failure due to resource starvation of system components.
By default, OpenShift Container Platform uses a script on each worker node to automatically determine the optimal system-reserved CPU and memory resources for nodes associated with a specific machine config pool and update the nodes with those values. The script runs on node start up.
|
|
If you updated your cluster from a version earlier than 4.21, automatic allocation of system resources is disabled by default. To enable the feature, delete the |
However, you can manually set these values by using a KubeletConfig custom resource (CR) that includes a set of <resource_type>=<resource_quantity> pairs (for example, cpu=200m,memory=512Mi). You must use the spec.autoSizingReserved: false parameter in the KubeletConfig CR to override the default OpenShift Container Platform behavior of automatically setting the systemReserved values.
For memory and ephemeral-storage, you specify the resource quantity in units of bytes, such as 200Ki, 50Mi, or 5Gi. By default, the system-reserved CPU is 500m and system-reserved memory is 1Gi. For the cpu type, you specify the resource quantity in units of cores, such as 200m, 0.5, or 1. Note that 1000 millicores is equal to 1CPU/vCPU.
|
|
|
-
Obtain the label associated with the static
MachineConfigPoolCRD for the type of node you want to configure by entering the following command:
-
Create a custom resource (CR) for your configuration change.
Sample configuration for a resource allocation CRapiVersion: machineconfiguration.openshift.io/v1 kind: KubeletConfig metadata: name: set-allocatable spec: autoSizingReserved: false machineConfigPoolSelector: matchLabels: pools.operator.machineconfiguration.openshift.io/worker: "" kubeletConfig: systemReserved: cpu: 1000m memory: 4Gi ephemeral-storage: 50Mi #...metadata.name-
Specifies a name for the CR.
spec.autoSizingReserved-
Specify
falseto override the default OpenShift Container Platform behavior of automatically setting thesystemReservedvalues. spec.machineConfigPoolSelector.matchLabels-
Specifies a label from the machine config pool.
spec.kubeletConfig.systemReserved-
Specifies the resources to reserve for the node components and system components.
-
Run the following command to create the CR:
$ oc create -f <file_name>.yaml
-
Log in to a node you configured by entering the following command:
$ oc debug node/<node_name> -
Set
/hostas the root directory within the debug shell:# chroot /host -
View the
/etc/node-sizing.envfile:Example outputSYSTEM_RESERVED_MEMORY=4Gi SYSTEM_RESERVED_CPU=1000m SYSTEM_RESERVED_ES=50MiThe kubelet uses the
system-reservedvalues in the/etc/node-sizing.envfile.