|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * machine_configuration/coreos-layering.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="coreos-layering-configuring-on-modifying_{context}"] |
| 7 | += Modifying a custom layered image |
| 8 | + |
| 9 | +You can modify an on-cluster custom layered image, as needed. This allows you to install additional packages, remove existing packages, change the pull or push repositories, update secrets, or other similar changes. You can edit the `MachineOSConfig` object, apply changes to the YAML file that created the `MachineOSConfig` object, or create a new YAML file for that purpose. |
| 10 | + |
| 11 | +If you modify and apply the `MachineOSConfig` object YAML or create a new YAML file, the YAML overwrites any changes you made directly to the `MachineOSConfig` object itself. |
| 12 | + |
| 13 | +include::snippets//coreos-layering-configuring-on-pause.adoc[] |
| 14 | + |
| 15 | +.Prerequisites |
| 16 | + |
| 17 | +* You have opted in to on-cluster layering by creating a `MachineOSConfig` object. |
| 18 | +
|
| 19 | +.Procedure |
| 20 | + |
| 21 | +* Modify an object to update the associated custom layered image: |
| 22 | +
|
| 23 | +.. Edit the `MachineOSConfig` object to modify the custom layered image. The following example adds the `rngd` daemon to nodes that already have the tree package that was installed using a custom layered image. |
| 24 | ++ |
| 25 | +[source,yaml] |
| 26 | +---- |
| 27 | +apiVersion: machineconfiguration.openshift.io/v1alpha1 |
| 28 | +kind: MachineOSConfig |
| 29 | +metadata: |
| 30 | + name: layered-alpha1 |
| 31 | +spec: |
| 32 | + machineConfigPool: |
| 33 | + name: layered |
| 34 | + buildInputs: |
| 35 | + containerFile: |
| 36 | + - containerfileArch: noarch |
| 37 | + content: |- <1> |
| 38 | + FROM configs AS final |
| 39 | +
|
| 40 | + RUN rpm-ostree install rng-tools && \ |
| 41 | + systemctl enable rngd && \ |
| 42 | + rpm-ostree cleanup -m && \ |
| 43 | + ostree container commit |
| 44 | +
|
| 45 | + RUN rpm-ostree install tree && \ |
| 46 | + ostree container commit |
| 47 | + imageBuilder: |
| 48 | + imageBuilderType: PodImageBuilder |
| 49 | + baseImagePullSecret: |
| 50 | + name: global-pull-secret-copy <2> |
| 51 | + renderedImagePushspec: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/os-images:latest <3> |
| 52 | + renderedImagePushSecret: <4> |
| 53 | + name: new-secret-name |
| 54 | + buildOutputs: |
| 55 | + currentImagePullSecret: |
| 56 | + name: new-secret-name <5> |
| 57 | +---- |
| 58 | +<1> Optional: Modify the Containerfile, for example to add or remove packages. |
| 59 | +<2> Optional: Update the secret needed to pull the base operating system image from the registry. |
| 60 | +<3> Optional: Modify the image registry to push the newly-built custom layered image to. |
| 61 | +<4> Optional: Update the secret needed to push the newly-built custom layered image to the registry. |
| 62 | +<5> Optional: Update the secret needed to pull the newly-built custom layered image from the registry. |
| 63 | ++ |
| 64 | +When you save the changes, the MCO drains, cordons, and reboots the nodes. After the reboot, the node uses the cluster base {op-system-first} image. If your changes modify a secret only, no new build is triggered and no reboot is performed. |
| 65 | + |
| 66 | +.Verification |
| 67 | + |
| 68 | +. Verify that the new `MachineOSBuild` object was created by using the following command: |
| 69 | ++ |
| 70 | +[source,terminal] |
| 71 | +---- |
| 72 | +$ oc get machineosbuild |
| 73 | +---- |
| 74 | ++ |
| 75 | +.Example output |
| 76 | +[source,terminal] |
| 77 | +---- |
| 78 | +NAME PREPARED BUILDING SUCCEEDED INTERRUPTED FAILED |
| 79 | +layered-a5457b883f5239cdcb71b57e1a30b6ef False False True False False |
| 80 | +layered-f91f0f5593dd337d89bf4d38c877590b False True False False False <1> |
| 81 | +---- |
| 82 | +<1> The value `True` in the `BUILDING` column indicates that the `MachineOSBuild` object is building. When the `SUCCEEDED` column reports `True`, the build is complete. |
| 83 | + |
| 84 | +. You can watch as the new machine config is rolled out to the nodes by using the following command: |
| 85 | ++ |
| 86 | +[source,terminal] |
| 87 | +---- |
| 88 | +$ oc get machineconfigpools |
| 89 | +---- |
| 90 | ++ |
| 91 | +.Example output |
| 92 | +[source,terminal] |
| 93 | +---- |
| 94 | +NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE |
| 95 | +layered rendered-layered-221507009cbcdec0eec8ab3ccd789d18 False True False 1 0 0 0 167m <1> |
| 96 | +master rendered-master-a0b404d061a6183cc36d302363422aba True False False 3 3 3 0 3h38m |
| 97 | +worker rendered-worker-221507009cbcdec0eec8ab3ccd789d18 True False False 2 2 2 0 3h38m |
| 98 | +---- |
| 99 | +<1> The value `FALSE` in the `UPDATED` column indicates that the `MachineOSBuild` object is building. When the `UPDATED` column reports `FALSE`, the new custom layered image has rolled out to the nodes. |
| 100 | + |
| 101 | +. When the node is back in the `Ready` state, check that the changes were applied: |
| 102 | + |
| 103 | +.. Open an `oc debug` session to the node by running the following command: |
| 104 | ++ |
| 105 | +[source,terminal] |
| 106 | +---- |
| 107 | +$ oc debug node/<node_name> |
| 108 | +---- |
| 109 | + |
| 110 | +.. Set `/host` as the root directory within the debug shell by running the following command: |
| 111 | ++ |
| 112 | +[source,terminal] |
| 113 | +---- |
| 114 | +sh-5.1# chroot /host |
| 115 | +---- |
| 116 | + |
| 117 | +.. Use an appropriate command to verify that change was applied. The following examples shows that the `rngd` daemon was installed: |
| 118 | ++ |
| 119 | +[source,terminal] |
| 120 | +---- |
| 121 | +sh-5.1# rpm -qa |grep rng-tools |
| 122 | +---- |
| 123 | ++ |
| 124 | +.Example output |
| 125 | +[source,terminal] |
| 126 | +---- |
| 127 | +rng-tools-6.17-3.fc41.x86_64 |
| 128 | +---- |
| 129 | ++ |
| 130 | +[source,terminal] |
| 131 | +---- |
| 132 | +sh-5.1# rngd -v |
| 133 | +---- |
| 134 | ++ |
| 135 | +.Example output |
| 136 | +[source,terminal] |
| 137 | +---- |
| 138 | +rngd 6.16 |
| 139 | +---- |
0 commit comments