Este conteúdo não está disponível no idioma selecionado.
Chapter 4. Configuring MCO-related custom resources
Besides managing MachineConfig objects, the MCO manages two custom resources (CRs): KubeletConfig and ContainerRuntimeConfig. Those CRs let you change node-level settings impacting how the kubelet and CRI-O container runtime services behave.
4.1. Creating a KubeletConfig CR to edit kubelet parameters Copiar o linkLink copiado para a área de transferência!
The kubelet configuration is currently serialized as an Ignition configuration, so it can be directly edited. However, there is also a new kubelet-config-controller added to the Machine Config Controller (MCC). This lets you use a KubeletConfig custom resource (CR) to edit the kubelet parameters.
As the fields in the kubeletConfig object are passed directly to the kubelet from upstream Kubernetes, the kubelet validates those values directly. Invalid values in the kubeletConfig object might cause cluster nodes to become unavailable. For valid values, see the Kubernetes documentation.
Consider the following guidance:
-
Edit an existing
KubeletConfigCR to modify existing settings or add new settings, instead of creating a CR for each change. It is recommended that you create a CR only to modify a different machine config pool, or for changes that are intended to be temporary, so that you can revert the changes. -
Create one
KubeletConfigCR for each machine config pool with all the config changes you want for that pool. -
As needed, create multiple
KubeletConfigCRs with a limit of 10 per cluster. For the firstKubeletConfigCR, the Machine Config Operator (MCO) creates a machine config appended withkubelet. With each subsequent CR, the controller creates anotherkubeletmachine config with a numeric suffix. For example, if you have akubeletmachine config with a-2suffix, the nextkubeletmachine config is appended with-3.
If you are applying a kubelet or container runtime config to a custom machine config pool, the custom role in the machineConfigSelector must match the name of the custom machine config pool.
For example, because the following custom machine config pool is named infra, the custom role must also be infra:
If you want to delete the machine configs, delete them in reverse order to avoid exceeding the limit. For example, you delete the kubelet-3 machine config before deleting the kubelet-2 machine config.
If you have a machine config with a kubelet-9 suffix, and you create another KubeletConfig CR, a new machine config is not created, even if there are fewer than 10 kubelet machine configs.
Example KubeletConfig CR
oc get kubeletconfig
$ oc get kubeletconfig
NAME AGE set-kubelet-config 15m
NAME AGE
set-kubelet-config 15m
Example showing a KubeletConfig machine config
oc get mc | grep kubelet
$ oc get mc | grep kubelet
... 99-worker-generated-kubelet-1 b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.4.0 26m ...
...
99-worker-generated-kubelet-1 b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.4.0 26m
...
The following procedure is an example to show how to configure the maximum number of pods per node, the maximum PIDs per node, and the maximum container log size size on the worker nodes.
Prerequisites
Obtain the label associated with the static
MachineConfigPoolCR for the type of node you want to configure. Perform one of the following steps:View the machine config pool:
oc describe machineconfigpool <name>
$ oc describe machineconfigpool <name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc describe machineconfigpool worker
$ oc describe machineconfigpool workerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- If a label has been added it appears under
labels.
If the label is not present, add a key/value pair:
oc label machineconfigpool worker custom-kubelet=set-kubelet-config
$ oc label machineconfigpool worker custom-kubelet=set-kubelet-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
View the available machine configuration objects that you can select:
oc get machineconfig
$ oc get machineconfigCopy to Clipboard Copied! Toggle word wrap Toggle overflow By default, the two kubelet-related configs are
01-master-kubeletand01-worker-kubelet.Check the current value for the maximum pods per node:
oc describe node <node_name>
$ oc describe node <node_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc describe node ci-ln-5grqprb-f76d1-ncnqq-worker-a-mdv94
$ oc describe node ci-ln-5grqprb-f76d1-ncnqq-worker-a-mdv94Copy to Clipboard Copied! Toggle word wrap Toggle overflow Look for
value: pods: <value>in theAllocatablestanza:Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the worker nodes as needed:
Create a YAML file similar to the following that contains the kubelet configuration:
ImportantKubelet configurations that target a specific machine config pool also affect any dependent pools. For example, creating a kubelet configuration for the pool containing worker nodes will also apply to any subset pools, including the pool containing infrastructure nodes. To avoid this, you must create a new machine config pool with a selection expression that only includes worker nodes, and have your kubelet configuration target this new pool.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Use
podPidsLimitto set the maximum number of PIDs in any pod. -
Use
containerLogMaxSizeto set the maximum size of the container log file before it is rotated. Use
maxPodsto set the maximum pods per node.NoteThe rate at which the kubelet talks to the API server depends on queries per second (QPS) and burst values. The default values,
50forkubeAPIQPSand100forkubeAPIBurst, are sufficient if there are limited pods running on each node. It is recommended to update the kubelet QPS and burst rates if there are enough CPU and memory resources on the node.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Use
Update the machine config pool for workers with the label:
oc label machineconfigpool worker custom-kubelet=set-kubelet-config
$ oc label machineconfigpool worker custom-kubelet=set-kubelet-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
KubeletConfigobject:oc create -f change-maxPods-cr.yaml
$ oc create -f change-maxPods-cr.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the
KubeletConfigobject is created:oc get kubeletconfig
$ oc get kubeletconfigCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE set-kubelet-config 15m
NAME AGE set-kubelet-config 15mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Depending on the number of worker nodes in the cluster, wait for the worker nodes to be rebooted one by one. For a cluster with 3 worker nodes, this could take about 10 to 15 minutes.
Verify that the changes are applied to the node:
Check on a worker node that the
maxPodsvalue changed:oc describe node <node_name>
$ oc describe node <node_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Locate the
Allocatablestanza:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- In this example, the
podsparameter should report the value you set in theKubeletConfigobject.
Verify the change in the
KubeletConfigobject:oc get kubeletconfigs set-kubelet-config -o yaml
$ oc get kubeletconfigs set-kubelet-config -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow This should show a status of
Trueandtype:Success, as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2. Creating a ContainerRuntimeConfig CR to edit CRI-O parameters Copiar o linkLink copiado para a área de transferência!
You can change some of the settings associated with the OpenShift Container Platform CRI-O runtime for the nodes associated with a specific machine config pool (MCP). Using a ContainerRuntimeConfig custom resource (CR), you set the configuration values and add a label to match the MCP. The MCO then rebuilds the crio.conf and storage.conf configuration files on the associated nodes with the updated values.
To revert the changes implemented by using a ContainerRuntimeConfig CR, you must delete the CR. Removing the label from the machine config pool does not revert the changes.
You can modify the following settings by using a ContainerRuntimeConfig CR:
-
Log level: The
logLevelparameter sets the CRI-Olog_levelparameter, which is the level of verbosity for log messages. The default isinfo(log_level = info). Other options includefatal,panic,error,warn,debug, andtrace. -
Overlay size: The
overlaySizeparameter sets the CRI-O Overlay storage driversizeparameter, which is the maximum size of a container image. -
Container runtime: The
defaultRuntimeparameter sets the container runtime to eitherruncorcrun. The default isrunc.
You should have one ContainerRuntimeConfig CR for each machine config pool with all the config changes you want for that pool. If you are applying the same content to all the pools, you only need one ContainerRuntimeConfig CR for all the pools.
You should edit an existing ContainerRuntimeConfig CR to modify existing settings or add new settings instead of creating a new CR for each change. It is recommended to create a new ContainerRuntimeConfig CR only to modify a different machine config pool, or for changes that are intended to be temporary so that you can revert the changes.
You can create multiple ContainerRuntimeConfig CRs, as needed, with a limit of 10 per cluster. For the first ContainerRuntimeConfig CR, the MCO creates a machine config appended with containerruntime. With each subsequent CR, the controller creates a new containerruntime machine config with a numeric suffix. For example, if you have a containerruntime machine config with a -2 suffix, the next containerruntime machine config is appended with -3.
If you want to delete the machine configs, you should delete them in reverse order to avoid exceeding the limit. For example, you should delete the containerruntime-3 machine config before deleting the containerruntime-2 machine config.
If you have a machine config with a containerruntime-9 suffix, and you create another ContainerRuntimeConfig CR, a new machine config is not created, even if there are fewer than 10 containerruntime machine configs.
Example showing multiple ContainerRuntimeConfig CRs
oc get ctrcfg
$ oc get ctrcfg
Example output
NAME AGE ctr-overlay 15m ctr-level 5m45s
NAME AGE
ctr-overlay 15m
ctr-level 5m45s
Example showing multiple containerruntime machine configs
oc get mc | grep container
$ oc get mc | grep container
Example output
The following example sets the log_level field to debug and sets the overlay size to 8 GB:
Example ContainerRuntimeConfig CR
- 1
- Specifies the machine config pool label. For a container runtime config, the role must match the name of the associated machine config pool.
- 2
- Optional: Specifies the level of verbosity for log messages.
- 3
- Optional: Specifies the maximum size of a container image.
- 4
- Optional: Specifies the container runtime to deploy to new containers. The default value is
runc.
Procedure
To change CRI-O settings using the ContainerRuntimeConfig CR:
Create a YAML file for the
ContainerRuntimeConfigCR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
ContainerRuntimeConfigCR:oc create -f <file_name>.yaml
$ oc create -f <file_name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the CR is created:
oc get ContainerRuntimeConfig
$ oc get ContainerRuntimeConfigCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE overlay-size 3m19s
NAME AGE overlay-size 3m19sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check that a new
containerruntimemachine config is created:oc get machineconfigs | grep containerrun
$ oc get machineconfigs | grep containerrunCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
99-worker-generated-containerruntime 2c9371fbb673b97a6fe8b1c52691999ed3a1bfc2 3.4.0 31s
99-worker-generated-containerruntime 2c9371fbb673b97a6fe8b1c52691999ed3a1bfc2 3.4.0 31sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Monitor the machine config pool until all are shown as ready:
oc get mcp worker
$ oc get mcp workerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-169 False True False 3 1 1 0 9h
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-169 False True False 3 1 1 0 9hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the settings were applied in CRI-O:
Open an
oc debugsession to a node in the machine config pool and runchroot /host.oc debug node/<node_name>
$ oc debug node/<node_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow chroot /host
sh-4.4# chroot /hostCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the changes in the
crio.conffile:crio config | grep 'log_level'
sh-4.4# crio config | grep 'log_level'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
log_level = "debug"
log_level = "debug"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the changes in the `storage.conf`file:
head -n 7 /etc/containers/storage.conf
sh-4.4# head -n 7 /etc/containers/storage.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3. Setting the default maximum container root partition size for Overlay with CRI-O Copiar o linkLink copiado para a área de transferência!
The root partition of each container shows all of the available disk space of the underlying host. Follow this guidance to set a maximum partition size for the root disk of all containers.
To configure the maximum Overlay size, as well as other CRI-O options like the log level, you can create the following ContainerRuntimeConfig custom resource definition (CRD):
Procedure
Create the configuration object:
oc apply -f overlaysize.yml
$ oc apply -f overlaysize.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow To apply the new CRI-O configuration to your worker nodes, edit the worker machine config pool:
oc edit machineconfigpool worker
$ oc edit machineconfigpool workerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
custom-criolabel based on thematchLabelsname you set in theContainerRuntimeConfigCRD:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save the changes, then view the machine configs:
oc get machineconfigs
$ oc get machineconfigsCopy to Clipboard Copied! Toggle word wrap Toggle overflow New
99-worker-generated-containerruntimeandrendered-worker-xyzobjects are created:Example output
99-worker-generated-containerruntime 4173030d89fbf4a7a0976d1665491a4d9a6e54f1 3.4.0 7m42s rendered-worker-xyz 4173030d89fbf4a7a0976d1665491a4d9a6e54f1 3.4.0 7m36s
99-worker-generated-containerruntime 4173030d89fbf4a7a0976d1665491a4d9a6e54f1 3.4.0 7m42s rendered-worker-xyz 4173030d89fbf4a7a0976d1665491a4d9a6e54f1 3.4.0 7m36sCopy to Clipboard Copied! Toggle word wrap Toggle overflow After those objects are created, monitor the machine config pool for the changes to be applied:
oc get mcp worker
$ oc get mcp workerCopy to Clipboard Copied! Toggle word wrap Toggle overflow The worker nodes show
UPDATINGasTrue, as well as the number of machines, the number updated, and other details:Example output
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-xyz False True False 3 2 2 0 20h
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-xyz False True False 3 2 2 0 20hCopy to Clipboard Copied! Toggle word wrap Toggle overflow When complete, the worker nodes transition back to
UPDATINGasFalse, and theUPDATEDMACHINECOUNTnumber matches theMACHINECOUNT:Example output
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-xyz True False False 3 3 3 0 20h
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-xyz True False False 3 3 3 0 20hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Looking at a worker machine, you see that the new 8 GB max size configuration is applied to all of the workers:
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Looking inside a container, you see that the root partition is now 8 GB:
Example output
~ $ df -h Filesystem Size Used Available Use% Mounted on overlay 8.0G 8.0K 8.0G 0% /
~ $ df -h Filesystem Size Used Available Use% Mounted on overlay 8.0G 8.0K 8.0G 0% /Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Creating a drop-in file for the default CRI-O capabilities Copiar o linkLink copiado para a área de transferência!
You can change some of the settings associated with the OpenShift Container Platform CRI-O runtime for the nodes associated with a specific machine config pool (MCP). By using a controller custom resource (CR), you set the configuration values and add a label to match the MCP. The Machine Config Operator (MCO) then rebuilds the crio.conf and default.conf configuration files on the associated nodes with the updated values.
Earlier versions of OpenShift Container Platform included specific machine configs by default. If you updated to a later version of OpenShift Container Platform, those machine configs were retained to ensure that clusters running on the same OpenShift Container Platform version have the same machine configs.
You can create multiple ContainerRuntimeConfig CRs, as needed, with a limit of 10 per cluster. For the first ContainerRuntimeConfig CR, the MCO creates a machine config appended with containerruntime. With each subsequent CR, the controller creates a containerruntime machine config with a numeric suffix. For example, if you have a containerruntime machine config with a -2 suffix, the next containerruntime machine config is appended with -3.
If you want to delete the machine configs, delete them in reverse order to avoid exceeding the limit. For example, delete the containerruntime-3 machine config before you delete the containerruntime-2 machine config.
If you have a machine config with a containerruntime-9 suffix and you create another ContainerRuntimeConfig CR, a new machine config is not created, even if there are fewer than 10 containerruntime machine configs.
Example of multiple ContainerRuntimeConfig CRs
oc get ctrcfg
$ oc get ctrcfg
Example output
NAME AGE ctr-overlay 15m ctr-level 5m45s
NAME AGE
ctr-overlay 15m
ctr-level 5m45s
Example showing multiple containerruntime related system configs
cat /proc/1/status | grep Cap
$ cat /proc/1/status | grep Cap
capsh --decode=<decode_CapBnd_value>
$ capsh --decode=<decode_CapBnd_value>
- 1
- Replace
<decode_CapBnd_value>with the specific value you want to decode.