You can change some of the settings associated with the {product-title} 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.
Note
|
To revert the changes implemented by using a |
You can modify the following settings by using a ContainerRuntimeConfig
CR:
-
PIDs limit: Setting the PIDs limit in the
ContainerRuntimeConfig
is expected to be deprecated. If PIDs limits are required, it is recommended to use thepodPidsLimit
field in theKubeletConfig
CR instead. The default value of thepodPidsLimit
field is4096
.NoteThe CRI-O flag is applied on the cgroup of the container, while the Kubelet flag is set on the cgroup of the pod. Please adjust the PIDs limit accordingly.
-
Log level: The
logLevel
parameter sets the CRI-Olog_level
parameter, 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
overlaySize
parameter sets the CRI-O Overlay storage driversize
parameter, which is the maximum size of a container image. -
Maximum log size: Setting the maximum log size in the
ContainerRuntimeConfig
is expected to be deprecated. If a maximum log size is required, it is recommended to use thecontainerLogMaxSize
field in theKubeletConfig
CR instead. -
Container runtime: The
defaultRuntime
parameter sets the container runtime to eitherrunc
orcrun
. 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.
Note
|
If you have a machine config with a |
ContainerRuntimeConfig
CRs$ oc get ctrcfg
NAME AGE
ctr-pid 24m
ctr-overlay 15m
ctr-level 5m45s
containerruntime
machine configs$ oc get mc | grep container
...
01-master-container-runtime b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 57m
...
01-worker-container-runtime b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 57m
...
99-worker-generated-containerruntime b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 26m
99-worker-generated-containerruntime-1 b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 17m
99-worker-generated-containerruntime-2 b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 7m26s
...
The following example raises the pids_limit
to 2048, sets the log_level
to debug
, sets the overlay size to 8 GB, and sets the log_size_max
to unlimited:
ContainerRuntimeConfig
CRapiVersion: machineconfiguration.openshift.io/v1
kind: ContainerRuntimeConfig
metadata:
name: overlay-size
spec:
machineConfigPoolSelector:
matchLabels:
pools.operator.machineconfiguration.openshift.io/worker: '' (1)
containerRuntimeConfig:
pidsLimit: 2048 (2)
logLevel: debug (3)
overlaySize: 8G (4)
logSizeMax: "-1" (5)
defaultRuntime: "crun" (6)
-
Specifies the machine config pool label.
-
Optional: Specifies the maximum number of processes allowed in a container.
-
Optional: Specifies the level of verbosity for log messages.
-
Optional: Specifies the maximum size of a container image.
-
Optional: Specifies the maximum size allowed for the container log file. If set to a positive number, it must be at least 8192.
-
Optional: Specifies the container runtime to deploy to new containers. The default is
runc
.
To change CRI-O settings using the ContainerRuntimeConfig
CR:
-
Create a YAML file for the
ContainerRuntimeConfig
CR:apiVersion: machineconfiguration.openshift.io/v1 kind: ContainerRuntimeConfig metadata: name: overlay-size spec: machineConfigPoolSelector: matchLabels: pools.operator.machineconfiguration.openshift.io/worker: '' (1) containerRuntimeConfig: (2) pidsLimit: 2048 logLevel: debug overlaySize: 8G logSizeMax: "-1"
-
Specify a label for the machine config pool that you want you want to modify.
-
Set the parameters as needed.
-
-
Create the
ContainerRuntimeConfig
CR:$ oc create -f <file_name>.yaml
-
Verify that the CR is created:
$ oc get ContainerRuntimeConfig
Example outputNAME AGE overlay-size 3m19s
-
Check that a new
containerruntime
machine config is created:$ oc get machineconfigs | grep containerrun
Example output99-worker-generated-containerruntime 2c9371fbb673b97a6fe8b1c52691999ed3a1bfc2 3.2.0 31s
-
Monitor the machine config pool until all are shown as ready:
$ oc get mcp worker
Example outputNAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE worker rendered-worker-169 False True False 3 1 1 0 9h
-
Verify that the settings were applied in CRI-O:
-
Open an
oc debug
session to a node in the machine config pool and runchroot /host
.$ oc debug node/<node_name>
sh-4.4# chroot /host
-
Verify the changes in the
crio.conf
file:sh-4.4# crio config | egrep 'log_level|pids_limit|log_size_max'
Example outputpids_limit = 2048 log_size_max = -1 log_level = "debug"
-
Verify the changes in the `storage.conf`file:
sh-4.4# head -n 7 /etc/containers/storage.conf
Example output[storage] driver = "overlay" runroot = "/var/run/containers/storage" graphroot = "/var/lib/containers/storage" [storage.options] additionalimagestores = [] size = "8G"
-