Skip to content

Commit 436178d

Browse files
author
Michael Burke
committed
Backport OCL to 4.18
1 parent a8f42bd commit 436178d

5 files changed

+147
-68
lines changed

machine_configuration/mco-coreos-layering.adoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ It is strongly recommended that you test your images outside of your production
182182
include::modules/coreos-layering-configuring-on.adoc[leveloffset=+1]
183183

184184
.Additional resources
185-
* xref:../nodes/clusters/nodes-cluster-enabling-features.adoc#nodes-cluster-enabling[Enabling features using feature gates]
186185
* xref:../updating/updating_a_cluster/update-using-custom-machine-config-pools.adoc#update-using-custom-machine-config-pools-pause_update-using-custom-machine-config-pools[Pausing the machine config pools]
186+
* xref:../machine_configuration/mco-coreos-layering.adoc#coreos-layering-configuring-on-remove_mco-coreos-layering[Removing an on-cluster custom layered image]
187+
* xref:../machine_configuration/mco-coreos-layering.adoc#coreos-layering-configuring-on-modifying_mco-coreos-layering[Modifying a custom layered image]
188+
* xref:../machine_configuration/mco-coreos-layering.adoc#coreos-layering-configuring-on-rebuild_mco-coreos-layering[Rebuilding an on-cluster custom layered image]
189+
* xref:../machine_configuration/mco-coreos-layering.adoc#coreos-layering-configuring-on-revert_mco-coreos-layering[Reverting an on-cluster custom layered image]
187190

188191
include::modules/coreos-layering-configuring-on-modifying.adoc[leveloffset=+2]
189192

@@ -199,11 +202,12 @@ include::modules/coreos-layering-configuring-on-extensions.adoc[leveloffset=+2]
199202
* xref:../updating/updating_a_cluster/update-using-custom-machine-config-pools.adoc#update-using-custom-machine-config-pools-pause_update-using-custom-machine-config-pools[Pausing the machine config pools]
200203
////
201204

202-
// Not in 4.18; maybe 4.19
203-
// include::modules/coreos-layering-configuring-on-rebuild.adoc[leveloffset=+2]
205+
include::modules/coreos-layering-configuring-on-rebuild.adoc[leveloffset=+2]
204206

205207
include::modules/coreos-layering-configuring-on-revert.adoc[leveloffset=+2]
206208

209+
include::modules/coreos-layering-configuring-on-remove.adoc[leveloffset=+2]
210+
207211
include::modules/coreos-layering-configuring.adoc[leveloffset=+1]
208212

209213
.Additional resources

modules/coreos-layering-configuring-on-modifying.adoc

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,32 @@ include::snippets//coreos-layering-configuring-on-pause.adoc[]
2424
+
2525
[source,yaml]
2626
----
27-
apiVersion: machineconfiguration.openshift.io/v1alpha1
27+
apiVersion: machineconfiguration.openshift.io/v1
2828
kind: MachineOSConfig
2929
metadata:
3030
name: layered
3131
spec:
3232
machineConfigPool:
33-
name: worker
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>
33+
name: layered
34+
containerFile:
35+
- containerfileArch: NoArch
36+
content: |- <1>
37+
FROM configs AS final
38+
RUN dnf install -y cowsay && \
39+
dnf clean all && \
40+
ostree container commit
41+
imageBuilder:
42+
imageBuilderType: Job
43+
baseImagePullSecret:
44+
name: global-pull-secret-copy <2>
45+
renderedImagePushSpec: image-registry.openshift-image-registry.svc:5000/openshift/os-image:latest <3>
46+
renderedImagePushSecret: <4>
47+
name: builder-dockercfg-mtcl23
5748
----
5849
<1> Optional: Modify the Containerfile, for example to add or remove packages.
5950
<2> Optional: Update the secret needed to pull the base operating system image from the registry.
6051
<3> Optional: Modify the image registry to push the newly built custom layered image to.
6152
<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.
6353
+
6454
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.
6555

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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-rebuild_{context}"]
7+
= Rebuilding an on-cluster custom layered image
8+
9+
In situations where you want to rebuild an on-cluster custom layered image, you can either modify your `MachineOSConfig` object or add an annotation to the `MachineOSConfig` object. Both of these actions trigger an automatic rebuild of the object. For example, you could perform a rebuild if the you change the Containerfile or need to update the `osimageurl` location in a machine config.
10+
11+
After you add the annotation, the Machine Config Operator (MCO) deletes the current `MachineOSBuild` object and creates a new one in its place. When the build process is complete, the MCO automatically removes the annotation.
12+
13+
.Prerequisites
14+
15+
* You have opted-in to {image-mode-os-on-lower} by creating a `MachineOSConfig` object.
16+
17+
.Procedure
18+
19+
* Edit the `MachineOSConfig` object to add the `machineconfiguration.openshift.io/rebuild` annotation by using the following command:
20+
+
21+
[source,terminal]
22+
----
23+
$ oc edit MachineOSConfig <object_name>
24+
----
25+
+
26+
.Example `MachineOSConfig` object
27+
+
28+
[source,yaml]
29+
----
30+
apiVersion: machineconfiguration.openshift.io/v1
31+
kind: MachineOSConfig
32+
metadata:
33+
annotations:
34+
machineconfiguration.openshift.io/current-machine-os-build: layering-c26d4a003432df70ee66c83981144cfa
35+
machineconfiguration.openshift.io/rebuild: "" <1>
36+
# ...
37+
name: layered
38+
# ...
39+
----
40+
<1> Add this annotation to trigger a rebuild of the custom layered image.
41+
42+
.Verification
43+
44+
* Check that the `MachineOSBuild` object is building by using the following command:
45+
+
46+
[source,terminal]
47+
----
48+
$ oc get machineosbuild
49+
----
50+
+
51+
.Example output
52+
[source,terminal]
53+
----
54+
NAME PREPARED BUILDING SUCCEEDED INTERRUPTED FAILED AGE
55+
layered-d6b929a29c6dbfa8e4007c8069a2fd08 False True False False False 2m41s <1>
56+
----
57+
<1> The value `True` in the `BUILDING` column indicates that the `MachineOSBuild` object is building.
58+
59+
* Edit the `MachineOSConfig` object to verify that the MCO removed the `machineconfiguration.openshift.io/rebuild` annotation by using the following command:
60+
+
61+
[source,terminal]
62+
----
63+
$ oc edit MachineOSConfig <object_name>
64+
----
65+
+
66+
.Example `MachineOSConfig` object
67+
+
68+
[source,yaml]
69+
----
70+
apiVersion: machineconfiguration.openshift.io/v1
71+
kind: MachineOSConfig
72+
metadata:
73+
annotations:
74+
machineconfiguration.openshift.io/current-machine-os-build: layering-c26d4a003432df70ee66c83981144cfa
75+
# ...
76+
name: layered
77+
# ...
78+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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-remove_{context}"]
7+
= Removing an on-cluster custom layered image
8+
9+
To prevent the custom layered images from taking up excessive space in your registry, you can automatically remove an on-cluster custom layered image from the repository by deleting the `MachineOSBuild` object that created the image.
10+
11+
The credentials provided by the registry push secret that you added to the `MachineOSBuild` object must grant the permission for deleting an image from the registry. If the delete permission is not provided, the image is not removed when you delete the `MachineOSBuild` object.
12+
13+
Note that the custom layered image is not deleted if the image is either currently in use on a node or is desired by the nodes, as indicated by the `machineconfiguration.openshift.io/currentConfig` or `machineconfiguration.openshift.io/desiredConfig` annotation on the node.

modules/coreos-layering-configuring-on.adoc

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ You should not need to interact with these new objects or the `machine-os-builde
4040

4141
You need a separate `MachineOSConfig` CR for each machine config pool where you want to use a custom layered image.
4242

43-
:FeatureName: On-cluster image layering
44-
include::snippets/technology-preview.adoc[]
4543
include::snippets//coreos-layering-configuring-on-pause.adoc[]
4644

4745
In the case of a build failure, for example due to network issues or an invalid secret, the MCO retries the build three additional times before the job fails. The MCO creates a different build pod for each build attempt. You can use the build pod logs to troubleshoot any build failures. However, the MCO automatically removes these build pods after a short period of time.
@@ -53,30 +51,31 @@ NAME PREPARED BUILDING SUCCEEDED INT
5351
layered-c8765e26ebc87e1e17a7d6e0a78e8bae False False False False True
5452
----
5553

56-
// Not in 4.18; maybe 4.19
57-
// You can manually rebuild your custom layered image by either modifying your `MachineOSConfig` object or applying an annotation to the `MachineOSConfig` object as discussed in the following section.
54+
You can manually rebuild your custom layered image by either modifying your `MachineOSConfig` object or applying an annotation to the `MachineOSConfig` object as discussed in the following section. For more information, see "Rebuilding an on-cluster custom layered image".
55+
56+
If you used a custom machine config pool to apply an on-cluster layered image to a node, you can remove the custom layered image from the node and revert to the base image. For more information, see "Reverting an on-cluster layered node".
57+
58+
You can modify an on-custom layered image as needed, to install additional packages, remove existing packages, change repositories, update secrets, or other similar changes, by editing the MachineOSConfig object. For more information, see "Modifying a custom layered image".
5859

5960
[discrete]
6061
[id="coreos-layering-configuring-on-limitations_{context}"]
61-
== On-cluster layering Technology Preview known limitations
62+
== On-cluster layering known limitations
6263

6364
Note the following limitations when working with the on-cluster layering feature:
6465

6566
* On-cluster layering is supported only for {product-title} clusters on the AMD64 architecture.
66-
* On-cluster layering is not supported on multi-architecture compute machines, {sno}, or disconnected clusters.
67+
* On-cluster layering is not supported on multi-architecture compute machines, or {sno} clusters.
6768
* If you scale up a machine set that uses a custom layered image, the nodes reboot two times. The first, when the node is initially created with the base image and a second time when the custom layered image is applied.
6869
* Node disruption policies are not supported on nodes with a custom layered image. As a result the following configuration changes cause a node reboot:
6970
** Modifying the configuration files in the `/var` or `/etc` directory
7071
** Adding or modifying a systemd service
7172
** Changing SSH keys
7273
** Removing mirroring rules from `ICSP`, `ITMS`, and `IDMS` objects
7374
** Changing the trusted CA, by updating the `user-ca-bundle` configmap in the `openshift-config` namespace
74-
* The images used in creating custom layered images take up space in your push registry. Always be aware of the free space in your registry and prune the images as needed.
75+
* The images used in creating custom layered images take up space in your push registry. Always be aware of the free space in your registry and prune the images as needed. You can automatically remove an on-cluster custom layered image from the repository by deleting the MachineOSBuild object that created the image. Note that the credentials provided by the registry push secret must also grant permission to delete an image from the registry. For more information, see "Removing an on-cluster custom layered image".
7576

7677
.Prerequisites
7778

78-
* You have enabled the `TechPreviewNoUpgrade` feature set by using the feature gates. For more information, see "Enabling features using feature gates".
79-
8079
* You have a copy of the pull secret in the `openshift-machine-config-operator` namespace that the MCO needs to pull the base operating system image.
8180
+
8281
For example, if you are using the global pull secret, you can run the following command:
@@ -98,7 +97,7 @@ $oc create secret docker-registry global-pull-secret-copy \
9897

9998
* You are familiar with how to configure a Containerfile. Instructions on how to create a Containerfile are beyond the scope of this documentation.
10099

101-
* Optional: You have a separate machine config pool for the nodes where you want to apply the custom layered image.
100+
* Optional: You have a separate machine config pool for the nodes where you want to apply the custom layered image. One benefit to having a custom machine config pool for the nodes it that you can easily revert to the base image, if needed. For more information, see "Reverting an on-cluster layered node".
102101

103102
.Procedure
104103

@@ -108,42 +107,37 @@ $oc create secret docker-registry global-pull-secret-copy \
108107
+
109108
[source,yaml]
110109
----
111-
apiVersion: machineconfiguration.openshift.io/v1alpha1 <1>
110+
apiVersion: machineconfiguration.openshift.io/v1 <1>
112111
kind: MachineOSConfig
113112
metadata:
114113
name: layered <2>
115114
spec:
116115
machineConfigPool:
117-
name: worker <3>
118-
buildInputs:
119-
containerFile: <4>
120-
- containerfileArch: noarch
121-
content: |-
122-
FROM configs AS final
123-
RUN rpm-ostree install tree && \
124-
ostree container commit
125-
imageBuilder: <5>
126-
imageBuilderType: PodImageBuilder
127-
baseImagePullSecret: <6>
128-
name: global-pull-secret-copy
129-
renderedImagePushspec: image-registry.openshift-image-registry.svc:5000/openshift/os-image:latest <7>
130-
renderedImagePushSecret: <8>
131-
name: builder-dockercfg-7lzwl
132-
buildOutputs: <9>
133-
currentImagePullSecret:
134-
name: builder-dockercfg-mtcl23
116+
name: layered <3>
117+
containerFile: # <4>
118+
- containerfileArch: NoArch <5>
119+
content: |-
120+
FROM configs AS final
121+
RUN dnf install -y cowsay && \
122+
dnf clean all && \
123+
ostree container commit
124+
imageBuilder: # <6>
125+
imageBuilderType: Job
126+
baseImagePullSecret: # <7>
127+
name: global-pull-secret-copy
128+
renderedImagePushSpec: image-registry.openshift-image-registry.svc:5000/openshift/os-image:latest # <8>
129+
renderedImagePushSecret: # <9>
130+
name: builder-dockercfg-mtcl23
135131
----
136132
<1> Specifies the `machineconfiguration.openshift.io/v1` API that is required for `MachineConfig` CRs.
137-
<2> Specifies a name for the `MachineOSConfig` object. This name is used with other on-cluster layering resources. The examples in this documentation use the name `layered`.
138-
<3> Specifies the name of the machine config pool associated with the nodes where you want to deploy the custom layered image. The examples in this documentation use the `worker` machine config pool.
133+
<2> Specifies a name for the `MachineOSConfig` object. This name is used with other [image-mode-os-on-lower] resources. The examples in this documentation use the name `layered`.
134+
<3> Specifies the name of the machine config pool associated with the nodes where you want to deploy the custom layered image. The examples in this documentation use the `layered` machine config pool.
139135
<4> Specifies the Containerfile to configure the custom layered image.
140-
<5> Specifies the name of the image builder to use. This must be `PodImageBuilder`.
141-
<6> Specifies the name of the pull secret that the MCO needs in order to pull the base operating system image from the registry.
142-
<7> Specifies the image registry to push the newly built custom layered image to. This can be any registry that your cluster has access to. This example uses the internal {product-title} registry.
143-
<8> Specifies the name of the push secret that the MCO needs in order to push the newly built custom layered image to that registry.
144-
<9> Specifies the secret required by the image registry that the nodes need in order to pull the newly built custom layered image. This should be a different secret than the one used to push the image to your repository.
145-
// +
146-
// https://github.com/openshift/openshift-docs/pull/87486/files has the v1 api versions
136+
<5> Specifies the architecture this containerfile is to be built for: `ARM64`, `AMD64`, `PPC64LE`, `S390X`, or `NoArch`. The default is `NoArch`, which defines a Containerfile that can be applied to any architecture.
137+
<6> Specifies the name of the image builder to use. This must be `Job`, which is a reference to the `job` object that is managing the image build.
138+
<7> Optional: Specifies the name of the pull secret that the MCO needs to pull the base operating system image from the registry. By default, the global pull secret is used.
139+
<8> Specifies the image registry to push the newly-built custom layered image to. This can be any registry that your cluster has access to in the `host[:port][/namespace]/name` or `svc_name.namespace.svc[:port]/repository/name:<tag>` format. This example uses the internal {product-title} registry. You can specify a mirror registry if you cluster is properly configured to use a mirror registry.
140+
<9> Specifies the name of the push secret that the MCO needs to push the newly-built custom layered image to that registry.
147141

148142
.. Create the `MachineOSConfig` object:
149143
+
@@ -230,7 +224,7 @@ $ oc describe machineosbuild <object_name>
230224
----
231225
Name: layered-ad5a3cad36303c363cf458ab0524e7c0
232226
# ...
233-
API Version: machineconfiguration.openshift.io/v1alpha1
227+
API Version: machineconfiguration.openshift.io/v1
234228
Kind: MachineOSBuild
235229
# ...
236230
Spec:

0 commit comments

Comments
 (0)