Skip to content

Commit e1f7748

Browse files
authored
Merge pull request #29273 from mburke5678/BZ-1825417
The containerruntimecontroller doesn't roll back to CR-1 if we delete CR-2
2 parents 903a10c + b3a299c commit e1f7748

File tree

1 file changed

+121
-26
lines changed

1 file changed

+121
-26
lines changed

modules/create-a-containerruntimeconfig-crd.adoc

Lines changed: 121 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,152 @@
55
[id="create-a-containerruntimeconfig_{context}"]
66
= Creating a `ContainerRuntimeConfig` CR to edit CRI-O parameters
77

8-
The `ContainerRuntimeConfig` custom resource definition (CRD) provides a structured way of changing settings associated with the {product-title} CRI-O runtime. Using a `ContainerRuntimeConfig` custom resource (CR), you select the configuration values you want and the MCO handles rebuilding the `crio.conf` and `storage.conf` configuration files.
8+
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.
99

10-
Parameters you can set in a `ContainerRuntimeConfig` CR include:
10+
[NOTE]
11+
====
12+
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.
13+
====
1114

12-
* **PIDs limit**: Sets the maximum number of processes allowed in a container. By default, the limit is set to 1024 (`pids_limit = 1024`).
13-
* **Log level**: Sets the level of verbosity for log messages. The default is `info` (`log_level = info`). Other options include `fatal`, `panic`, `error`, `warn`, `debug`, and `trace`.
14-
* **Overlay size**: Sets the maxim size of a container image. The default is 10 GB.
15-
* **Maximum log size**: Sets the maximum size allowed for the container log file. The default maximum log size is unlimited (`log_size_max = -1`). If it is set to a positive number, it must be at least 8192 to not be smaller than the `conmon` read buffer. Conmon is a program that
15+
You can modify the following settings by using a `ContainerRuntimeConfig` CR:
16+
17+
* **PIDs limit**: The `pidsLimit` parameter sets the CRI-O `pids_limit` parameter, which is maximum number of processes allowed in a container. The default is 1024 (`pids_limit = 1024`).
18+
* **Log level**: The `logLevel` parameter sets the CRI-O `log_level` parameter, which is the level of verbosity for log messages. The default is `info` (`log_level = info`). Other options include `fatal`, `panic`, `error`, `warn`, `debug`, and `trace`.
19+
* **Overlay size**: The `overlaySize` parameter sets the CRI-O Overlay storage driver `size` parameter, which is the maximum size of a container image. The default is 10 GB (size = "10G").
20+
* **Maximum log size**: The `logSizeMax` parameter sets the CRI-O `log_size_max` parameter, which is the maximum size allowed for the container log file. The default is unlimited (`log_size_max = -1`). If set to a positive number, it must be at least 8192 to not be smaller than the ConMon read buffer. ConMon is a program that
1621
monitors communications between a container manager (such as Podman or CRI-O) and the OCI runtime (such as runc or crun) for a single container.
1722

18-
The following procedure describes how to change CRI-O settings using the `ContainerRuntimeConfig` CR.
23+
You can create multiple `ContainerRuntimeConfig` CRs, as needed, with a limit of ten. 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`.
24+
25+
You can also edit an existing `ContainerRuntimeConfig` CRs to edit existing settings or add new settings instead of creating a new CR. It is recommended to create a new CR to modify a different machine config pool, rather than add additional labels to an existing CR.
26+
27+
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.
28+
29+
[NOTE]
30+
====
31+
If you have a machine config with a `containerruntime-9` suffix, the next machine config is appended with `containerruntime-10` and will fail as it exceeds the limit, even if there are fewer than 10 `containerruntime` machine configs.
32+
====
33+
34+
.Example showing multiple `ContainerRuntimeConfig` CRs
35+
[source,terminal]
36+
----
37+
$ oc get ctrcfg
38+
----
39+
40+
.Example output
41+
[source, terminal]
42+
----
43+
NAME AGE
44+
ctr-pid 24m
45+
ctr-overlay 15m
46+
ctr-level 5m45s
47+
----
48+
49+
.Example showing multiple `containerruntime` machine configs
50+
[source,terminal]
51+
----
52+
$ oc get mc | grep container
53+
----
54+
55+
.Example output
56+
[source, terminal]
57+
----
58+
...
59+
01-master-container-runtime b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 57m
60+
...
61+
01-worker-container-runtime b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 57m
62+
...
63+
99-worker-generated-containerruntime b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 26m
64+
99-worker-generated-containerruntime-1 b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 17m
65+
99-worker-generated-containerruntime-2 b5c5119de007945b6fe6fb215db3b8e2ceb12511 3.2.0 7m26s
66+
...
67+
----
68+
69+
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:
1970

71+
.Example `ContainerRuntimeConfig` CR
72+
[source,yaml]
73+
----
74+
apiVersion: machineconfiguration.openshift.io/v1
75+
kind: ContainerRuntimeConfig
76+
metadata:
77+
name: overlay-size
78+
spec:
79+
machineConfigPoolSelector:
80+
matchLabels:
81+
pools.operator.machineconfiguration.openshift.io/worker: '' <1>
82+
containerRuntimeConfig:
83+
pidsLimit: 2048 <2>
84+
logLevel: debug <3>
85+
overlaySize: 8G <4>
86+
logSizeMax: "-1" <5>
87+
----
88+
<1> Specifies the machine config pool label.
89+
<2> Optional: Specifies the level of verbosity for log messages.
90+
<3> Optional: Specifies the maximum size allowed for the container log file. If set to a positive number, it must be at least `8192`.
91+
<4> Optional: Specifies the maximum size of a container image.
92+
<5> Optional: Specifies the maximum number of processes allowed in a container.
93+
2094
.Procedure
2195

22-
. To raise the `pidsLimit` to 2048, set the `logLevel` to `debug`, and set the `overlaySize` to 8 GB, create a CR file (for example, `overlay-size.yaml`) that contains that setting:
96+
To change CRI-O settings using the `ContainerRuntimeConfig` CR:
97+
98+
. Create a YAML file for the `ContainerRuntimeConfig` CR:
2399
+
24100
[source,yaml]
25101
----
26-
$ cat << EOF > /tmp/overlay-size.yaml
27102
apiVersion: machineconfiguration.openshift.io/v1
28103
kind: ContainerRuntimeConfig
29104
metadata:
30105
name: overlay-size
31106
spec:
32107
machineConfigPoolSelector:
33108
matchLabels:
34-
custom-crio: overlay-size
35-
containerRuntimeConfig:
109+
pools.operator.machineconfiguration.openshift.io/worker: '' <1>
110+
containerRuntimeConfig: <2>
36111
pidsLimit: 2048
37112
logLevel: debug
38113
overlaySize: 8G
39-
EOF
114+
logSizeMax: "-1"
40115
----
116+
<1> Specify a label for the machine config pool that you want you want to modify.
117+
<2> Set the parameters as needed.
41118

42-
. To apply the `ContainerRuntimeConfig` object settings, run:
119+
. Create the `ContainerRuntimeConfig` CR:
43120
+
44121
[source,terminal]
45122
----
46-
$ oc create -f /tmp/overlay-size
123+
$ oc create -f <file_name>.yaml
47124
----
48125

49-
. To verify that the settings wer applied, run:
126+
. Verify that the CR is created:
50127
+
51128
[source,terminal]
52129
----
53130
$ oc get ContainerRuntimeConfig
131+
----
132+
+
133+
.Example output
134+
[source,terminal]
135+
----
54136
NAME AGE
55137
overlay-size 3m19s
56-
57138
----
58139

59-
. To edit a pool of machines, such as `worker`, run the following command to open a machine config pool:
140+
. Check that a new `containerruntime` machine config is created:
60141
+
61142
[source,terminal]
62143
----
63-
$ oc edit machineconfigpool worker
144+
$ oc get machineconfigs | grep containerrun
64145
----
65-
66-
. Check that a new `containerruntime` object has appeared under the `machineconfigs`:
67146
+
147+
.Example output
68148
[source,terminal]
69149
----
70-
$ oc get machineconfigs | grep containerrun
71150
99-worker-generated-containerruntime 2c9371fbb673b97a6fe8b1c52691999ed3a1bfc2 3.1.0 31s
72151
----
73-
. Monitor the machine config pool as the changes are rolled into the machines until all are shown as ready:
152+
153+
. Monitor the machine config pool until all are shown as ready:
74154
+
75155
[source,terminal]
76156
----
@@ -85,26 +165,41 @@ NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMAC
85165
worker rendered-worker-169 False True False 3 1 1 0 9h
86166
----
87167

88-
. Open an `oc debug` session to a worker node and run `chroot /host`.
168+
. Verify that the settings were applied in CRI-O:
169+
170+
.. Open an `oc debug` session to a node in the machine config pool and run `chroot /host`.
171+
+
172+
[source, terminal]
173+
----
174+
$ oc debug node/<node_name>
175+
----
176+
+
177+
[source, terminal]
178+
----
179+
sh-4.4# chroot /host
180+
----
89181

90-
. Verify the changes by running:
182+
.. Verify the changes in the `crio.conf` file:
91183
+
92184
[source,terminal]
93185
----
94-
$ crio config | egrep 'log_level|pids_limit'
186+
sh-4.4# crio config | egrep 'log_level|pids_limit|log_size_max'
95187
----
96188
+
97189
.Example output
98190
+
99191
[source,terminal]
100192
----
101193
pids_limit = 2048
194+
log_size_max = -1
102195
log_level = "debug"
103196
----
197+
198+
.. Verify the changes in the `storage.conf`file:
104199
+
105200
[source,terminal]
106201
----
107-
$ head -n 7 /etc/containers/storage.conf
202+
sh-4.4# head -n 7 /etc/containers/storage.conf
108203
----
109204
+
110205
.Example output

0 commit comments

Comments
 (0)