Skip to content

Commit a4bd52b

Browse files
authored
Merge pull request #74675 from mburke5678/mco-garbage-collect
Garbage Collect old rendered MachineConfigs
2 parents 77b5aab + 9c219a8 commit a4bd52b

File tree

4 files changed

+136
-1
lines changed

4 files changed

+136
-1
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * post_installation_configuration/machine-configuration-tasks.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="machineconfig-garbage-collect-removing_{context}"]
7+
= Removing unused rendered machine configs
8+
9+
You can remove unused rendered machine configs by using the `oc adm prune renderedmachineconfigs` command with the `--confirm` command. If any rendered machine config is not deleted, the command output indicates which was not deleted and lists the reason for skipping the deletion.
10+
11+
.Procedure
12+
13+
. Optional: List the rendered machine configs that you can remove automatically by running the following command. Any rendered machine config marked with `as it's currently in use` in the command output is not removed.
14+
+
15+
[source,terminal]
16+
----
17+
$ oc adm prune renderedmachineconfigs --pool-name=worker
18+
----
19+
+
20+
.Example output
21+
[source,terminal]
22+
----
23+
Dry run enabled - no modifications will be made. Add --confirm to remove rendered machine configs.
24+
DRY RUN: Deleted rendered MachineConfig rendered-worker-23d7322831a57f02998e7e1600a0865f
25+
DRY RUN: Deleted rendered MachineConfig rendered-worker-fc94397dc7c43808c7014683c208956e
26+
DRY RUN: Skipping deletion of rendered MachineConfig rendered-worker-ad5a3cad36303c363cf458ab0524e7c0 as it's currently in use
27+
----
28+
+
29+
--
30+
where:
31+
32+
pool-name:: Optional: Specifies the machine config pool where you want to delete the machine configs from.
33+
--
34+
35+
. Remove the unused rendered machine configs by running the following command. The command in the following procedure would delete the two oldest unused rendered machine configs in the `worker` machine config pool.
36+
+
37+
[source,terminal]
38+
----
39+
$ oc adm prune renderedmachineconfigs --pool-name=worker --count=2 --confirm
40+
----
41+
+
42+
--
43+
where:
44+
45+
`--count`:: Optional: Specifies the maximum number of unused rendered machine configs you want to delete, starting with the oldest.
46+
47+
`--confirm`:: Optional: Specifies the maximum number of unused rendered machine configs you want to delete, starting with the oldest.
48+
49+
`--pool-name`:: Optional: Specifies the machine config pool from which you want to delete the machine. If not specified, all the pools are evaluated.
50+
51+
--
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * post_installation_configuration/machine-configuration-tasks.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="machineconfig-garbage-collect-viewing_{context}"]
7+
= Viewing rendered machine configs
8+
9+
You can view a list of rendered machine configs by using the `oc adm prune renderedmachineconfigs` command with the `list` subcommand.
10+
11+
For example, the command in the following procedure would list all rendered machine configs for the `worker` machine config pool.
12+
13+
.Procedure
14+
15+
* Optional: List the rendered machine configs by using the following command:
16+
+
17+
[source,terminal]
18+
----
19+
$ oc adm prune renderedmachineconfigs list --in-use=false --pool-name=worker
20+
----
21+
+
22+
--
23+
where:
24+
25+
list:: Displays a list of rendered machine configs in your cluster.
26+
27+
`--in-use`:: Optional: Specifies whether to display only the used machine configs or all machine configs from the specified pool. If `true`, the output lists the rendered machine configs that are being used by a machine config pool. If `false`, the output lists all rendered machine configs in the cluster. The default value is `false`.
28+
29+
`--pool-name`:: Optional: Specifies the machine config pool from which to display the machine configs.
30+
--
31+
+
32+
.Example output
33+
[source,terminal]
34+
----
35+
worker
36+
status: rendered-worker-ae115e2b5e6ae05e0e6e5d62c7d0dd81
37+
spec: rendered-worker-ae115e2b5e6ae05e0e6e5d62c7d0dd81
38+
----
39+
40+
* List the rendered machine configs that you can remove automatically by running the following command. Any rendered machine config marked with `as it's currently in use` in the command output is not removed.
41+
+
42+
[source,terminal]
43+
----
44+
$ oc adm prune renderedmachineconfigs --pool-name=worker
45+
----
46+
+
47+
The command runs in dry-run mode, and no machine configs are removed.
48+
+
49+
--
50+
where:
51+
52+
`--pool-name`:: Optional: Displays the machine configs in the specified machine config pool.
53+
--
54+
+
55+
.Example output
56+
[source,terminal]
57+
----
58+
Dry run enabled - no modifications will be made. Add --confirm to remove rendered machine configs.
59+
DRY RUN: Deleted rendered MachineConfig rendered-worker-23d7322831a57f02998e7e1600a0865f
60+
DRY RUN: Deleted rendered MachineConfig rendered-worker-fc94397dc7c43808c7014683c208956e
61+
DRY RUN: Skipping deletion of rendered MachineConfig rendered-worker-ad5a3cad36303c363cf458ab0524e7c0 as it's currently in use
62+
----
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * post_installation_configuration/machine-configuration-tasks.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="machineconfig-garbage-collect_{context}"]
7+
= Managing unused rendered machine configs
8+
9+
The Machine Config Operator (MCO) does not perform any garbage collection activities. This means that all rendered machine configs remain in the cluster. Each time a user or controller applies a new machine config, the MCO creates new rendered configs for each affected machine config pool. Over time, this can lead to a large number of rendered machine configs, which can make working with machine configs confusing. Having too many rendered machine configs can also contribute to disk space issues and performance issues with etcd.
10+
11+
You can remove old, unused rendered machine configs by using the `oc adm prune renderedmachineconfigs` command with the `--confirm` flag. With this command, you can remove all unused rendered machine configs or only those in a specific machine config pool. You can also remove a specified number of unused rendered machine configs in order to keep some older machine configs, in case you want to check older configurations.
12+
13+
You can use the `oc adm prune renderedmachineconfigs` command without the `--confirm` flag to see which rendered machine configs would be removed.
14+
15+
Use the `list` subcommand to display all the rendered machine configs in the cluster or a specific machine config pool.
16+
17+
[NOTE]
18+
====
19+
The `oc adm prune renderedmachineconfigs` command deletes only rendered machine configs that are not in use. If a rendered machine configs are in use by a machine config pool, the rendered machine config is not deleted. In this case, the command output specifies the reason that the rendered machine config was not deleted.
20+
====

post_installation_configuration/machine-configuration-tasks.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ include::modules/create-a-kubeletconfig-crd-to-edit-kubelet-parameters.adoc[leve
8686
include::modules/create-a-containerruntimeconfig-crd.adoc[leveloffset=+2]
8787
include::modules/set-the-default-max-container-root-partition-size-for-overlay-with-crio.adoc[leveloffset=+2]
8888

89-
89+
include::modules/machineconfig-garbage-collect.adoc[leveloffset=+1]
90+
include::modules/machineconfig-garbage-collect-viewing.adoc[leveloffset=+2]
91+
include::modules/machineconfig-garbage-collect-removing.adoc[leveloffset=+2]

0 commit comments

Comments
 (0)