Chapter 1. Embedding in a RHEL for Edge image using image builder
Use the image builder tool to create a customized RHEL image that contains MicroShift.
1.1. Preparing for image building Copy linkLink copied to clipboard!
Use the image builder tool to compose customized Red Hat Enterprise Linux for Edge (RHEL for Edge) images optimized for edge deployments.
You can run a MicroShift node with your applications on a RHEL for Edge virtual machine for development and testing first, then use your whole solution in edge production environments.
Use the following RHEL documentation to understand the full details of using RHEL for Edge:
- Introduction to RHEL for Edge images
To build an Red Hat Enterprise Linux for Edge (RHEL for Edge) 9.4 image for a given CPU architecture, you need a RHEL 9.4 build host of the same CPU architecture that meets the image builder system requirements. See the following link for more information:
To install image builder and the
composer-clitool, use the following instructions:
1.2. Enabling extended support repositories for image building Copy linkLink copied to clipboard!
If you have an extended support (EUS) release of MicroShift or Red Hat Enterprise Linux (RHEL), you must enable the RHEL EUS repositories for image builder to use. If you do not have an EUS version, you can skip these steps.
Prerequisites
- You have either an EUS version of MicroShift or RHEL, or you are updating to one.
- You have root-user access to your build host.
You have reviewed the following link:
Red Hat Device Edge release compatibility matrix
WarningKeeping component versions in a supported configuration of Red Hat Device Edge can require updating MicroShift and RHEL at the same time. Ensure that your version of RHEL is compatible with the version of MicroShift you are updating to, especially if you are updating MicroShift across two minor versions. Otherwise, you can create an unsupported configuration, break your node, or both. For more information, see the following link:
Procedure
Create the
/etc/osbuild-composer/repositoriesdirectory by running the following command:$ sudo mkdir -p /etc/osbuild-composer/repositoriesCopy the
/usr/share/osbuild-composer/repositories/rhel-9.4.jsonfile into the/etc/osbuild-composer/repositoriesdirectory by running the following command:$ sudo cp /usr/share/osbuild-composer/repositories/rhel-9.4.json /etc/osbuild-composer/repositories/rhel-9.4.jsonUpdate the
baseossource by modifying the/etc/osbuild-composer/repositories/rhel-9.4.jsonfile with the following values:# ... "baseurl": "https://cdn.redhat.com/content/eus/rhel<9>/<9.4>//baseos/os", # ...Replace <9> with the major RHEL version you are using, and replace <9.4> with the <major.minor> version. Be certain that the RHEL version you choose is compatible with the MicroShift version you are using.
Optional. Apply the
baseosupdate by running the following command:$ sudo sed -i "s,dist/rhel<9>/<9.4>/$(uname -m)/baseos/,eus/rhel<9>/<9.4>/$(uname -m)/baseos/,g" \ /etc/osbuild-composer/repositories/rhel-<9.4>.jsonReplace <9> with the major RHEL version you are using, and replace <9.4> with the <major.minor> version. Be certain that the RHEL version you choose is compatible with the MicroShift version you are using.
Update the
appstreamsource by modifying the/etc/osbuild-composer/repositories/rhel-<major.minor>.jsonfile with the following values:# ... "baseurl": "https://cdn.redhat.com/content/eus/rhel<9>/<9.4>//appstream/os", # ...Replace <9> with the major RHEL version you are using, and replace <9.4> with the <major.minor> version. Be certain that the RHEL version you choose is compatible with the MicroShift version you are using.
Optional. Apply the
appstreamupdate by running the following command:$ sudo sed -i "s,dist/rhel<9>/<9.4>/$(uname -m)/appstream/,eus/rhel<9>/<9.4>/$(uname -m)/appstream/,g" \ /etc/osbuild-composer/repositories/rhel-<9.4>.jsonReplace <9> with the major RHEL version you are using, and replace <9.4> with the <major.minor> version. Be certain that the RHEL version you choose is compatible with the MicroShift version you are using.
Verification
Verify the
baseossource by running the following command:$ sudo composer-cli sources info baseos | grep 'url ='Example output
url = "https://cdn.redhat.com/content/eus/rhel9/9.4/x86_64/baseos/os"Verify the
appstreamsource by running the following command:$ sudo composer-cli sources info appstream | grep 'url ='Example output
url = "https://cdn.redhat.com/content/eus/rhel9/9.4/x86_64/appstream/os"
1.3. Adding MicroShift repositories to image builder Copy linkLink copied to clipboard!
Add the MicroShift repositories to image builder on your build host.
Prerequisites
- Your build host meets the image builder system requirements.
-
You have installed and set up image builder and the
composer-clitool. - You have root-user access to your build host.
Procedure
Create an image builder configuration file for adding the
rhocp-4.18RPM repository source required to pull MicroShift RPMs by running the following command:cat > rhocp-4.18.toml <<EOF id = "rhocp-4.18" name = "Red Hat OpenShift Container Platform 4.18 for RHEL 9" type = "yum-baseurl" url = "https://cdn.redhat.com/content/dist/layered/rhel9/$(uname -m)/rhocp/4.18/os" check_gpg = true check_ssl = true system = false rhsm = true EOFCreate an image builder configuration file for adding the
fast-datapathRPM repository by running the following command:cat > fast-datapath.toml <<EOF id = "fast-datapath" name = "Fast Datapath for RHEL 9" type = "yum-baseurl" url = "https://cdn.redhat.com/content/dist/layered/rhel9/$(uname -m)/fast-datapath/os" check_gpg = true check_ssl = true system = false rhsm = true EOFAdd the sources to the image builder by running the following commands:
$ sudo composer-cli sources add rhocp-4.18.toml$ sudo composer-cli sources add fast-datapath.toml
Verification
Confirm that the sources were added properly by running the following command:
$ sudo composer-cli sources listExample output
appstream baseos fast-datapath rhocp-4.18
Next steps
Create the blueprint. For more information, see the following links:
1.4. Adding the MicroShift service to a blueprint Copy linkLink copied to clipboard!
Adding the MicroShift RPM package to an image builder blueprint enables the build of a RHEL for Edge image with MicroShift embedded.
Procedure
Use the blueprint installed in the
/usr/share/microshift/blueprintdirectory that is specific to your platform architecture. See the following example snippet for an explanation of the blueprint sections:Generated image builder blueprint example snippet
name = "microshift_blueprint" description = "MicroShift 4.18.1 on x86_64 platform" version = "0.0.1" modules = [] groups = [] [[packages]] name = "microshift" version = "4.18.1" ... ... [customizations.services] enabled = ["microshift"] [customizations.firewall] ports = ["ssh"] ... ... [[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f41e79c17e8b41f1b0a5a32c3e2dd7cd15b8274554d3f1ba12b2598a347475f4" [[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dbc65f1fba7d92b36cf7514cd130fe83a9bd211005ddb23a8dc479e0eea645fd" ... … EOF-
[[packages]] name = "microshift": references for all non-optional MicroShift RPM packages using the same version compatible with themicroshift-release-infoRPM. -
[customizations.services] enabled = ["microshift"]: references for automatically enabling MicroShift on system startup and applying default networking settings. -
[[containers]] source = "quay.io/openshift-release-dev/…: references for all non-optional MicroShift container images necessary for an offline deployment. The SHA depends on the release you are using.
-
Add the blueprint to the image builder by running the following command:
$ sudo composer-cli blueprints push microshift_blueprint.toml
Verification
Verify the image builder configuration listing only MicroShift packages by running the following command:
$ sudo composer-cli blueprints depsolve microshift_blueprint | grep microshiftExample output
blueprint: microshift_blueprint v0.0.1 microshift-release-info-4.18.1-202511250827.p0.g4105d3b.assembly.4.18.1.el9.noarch microshift-4.18.1-202511250827.p0.g4105d3b.assembly.4.18.1.el9.x86_64Optional: Verify the image builder configuration that lists all of the components to be installed by running the following command:
$ sudo composer-cli blueprints depsolve microshift_blueprint
1.5. Adding other packages to a blueprint Copy linkLink copied to clipboard!
Add the references for optional RPM packages to your ostree blueprint to enable them.
Prerequisites
- You created an image builder blueprint file.
Procedure
Edit your
ostreeblueprint by running the following command:$ vi <microshift_blueprint.toml>Replace
<microshift_blueprint.toml>with the name of the blueprint file used for the MicroShift service.Add the following example text to your blueprint:
[[packages]] name = "<microshift_additional_package_name>" version = "*"-
[[packages]] name =Include one stanza for each additional service that you want to add. For example, replace<microshift_additional_package_name>in with the name the RPM for the service you want to include such asmicroshift-olm. Add another stanza as needed.
-
Next steps
Add custom certificate authorities to the blueprint as needed. For more information, see the following links:
After you finish adding to your blueprint, you can apply the manifests to an active node by building a new RHEL for Edge system and deploying it on the client:
- Create the ISO.
- Add the blueprint and build the ISO.
- Download the ISO and prepare it for use.
- Do any provisioning that is needed.
1.6. Certificate authority bundle configuration Copy linkLink copied to clipboard!
MicroShift uses the host trust bundle when clients evaluate server certificates.
You can also use a customized security certificate chain to improve the compatibility of your endpoint certificates with clients specific to your deployments. To do this, you can add a certificate authority (CA) bundle with root and intermediate certificates to the Red Hat Enterprise Linux for Edge (RHEL for Edge) system-wide truststore.
1.6.1. Adding a certificate authority bundle to a blueprint Copy linkLink copied to clipboard!
You can include additional certificate authorities (CAs) to be trusted by the operating system when pulling images from an image registry. To add the additional CAs to the Red Hat Enterprise Linux for Edge (RHEL for Edge) rpm-ostree image, configure them in the blueprint that you use to create the image.
This procedure requires you to configure the CA bundle customizations in the blueprint, and then add steps to your Kickstart file to enable the bundle. In the following steps, data is the key, and <value> represents the PEM-encoded certificate.
Prerequisites
- You have root user access to your build host.
- Your build host meets the image builder system requirements.
-
You have installed and set up image builder and the
composer-clitool.
Procedure
Add the following custom values to your blueprint to add a directory.
Add instructions to your blueprint on the host where the image is built to create the directory, for example,
/etc/pki/ca-trust/source/anchors/for your certificate bundles.[[customizations.directories]] path = "/etc/pki/ca-trust/source/anchors"After the image has booted, create the certificate bundles, for example,
/etc/pki/ca-trust/source/anchors/cert1.pem:[[customizations.files]] path = "/etc/pki/ca-trust/source/anchors/cert1.pem" data = "<value>"
To enable the certificate bundle in the system-wide truststore configuration, use the
update-ca-trustcommand on the host where the image you are using has booted, for example:$ sudo update-ca-trustNoteThe
update-ca-trustcommand might be included in the%postsection of a Kickstart file used for MicroShift host installation so that all the necessary certificate trust is enabled on the first boot. You must configure the CA bundle customizations in the blueprint before adding steps to your Kickstart file to enable the bundle.%post # Update certificate trust storage in case new certificates were # installed at /etc/pki/ca-trust/source/anchors directory update-ca-trust %end
1.7. Creating the RHEL for Edge image with image builder Copy linkLink copied to clipboard!
The RHEL for Edge Installer image pulls the commit from the running container and creates an installable boot ISO with a Kickstart file configured to use the embedded rpm-ostree commit.
Prerequisites
- Your build host meets the image builder system requirements.
-
You installed and set up image builder and the
composer-clitool. - You root-user access to your build host.
-
You installed the
podmantool.
Procedure
Start an
ostreecontainer image build by running the following command:$ BUILDID=$(sudo composer-cli compose start-ostree --ref "rhel/{op-system-version-major}/$(uname -m)/edge" <microshift_blueprint> edge-container | awk '/^Compose/ {print $2}')Replace
<microshift_blueprint>with the name of your blueprint.This command also returns the identification (ID) of the build for monitoring.
You can check the status of the build periodically by running the following command:
$ sudo composer-cli compose statusExample output of a running build
ID Status Time Blueprint Version Type Size cc3377ec-4643-4483-b0e7-6b0ad0ae6332 RUNNING Wed Jun 7 12:26:23 2023 microshift_blueprint 0.0.1 edge-containerExample output of a completed build
ID Status Time Blueprint Version Type Size cc3377ec-4643-4483-b0e7-6b0ad0ae6332 FINISHED Wed Jun 7 12:32:37 2023 microshift_blueprint 0.0.1 edge-containerNoteYou can use the
watchcommand to monitor your build if you are familiar with how to start and stop it.Download the container image using the ID and get the image ready for use by running the following command:
$ sudo composer-cli compose image ${BUILDID}Change the ownership of the downloaded container image to the current user by running the following command:
$ sudo chown $(whoami). ${BUILDID}-container.tarAdd read permissions for the current user to the image by running the following command:
$ sudo chmod a+r ${BUILDID}-container.tarBootstrap a server on port 8085 for the
ostreecontainer image to be consumed by the ISO build by completing the following steps:Get the
IMAGEIDvariable result by running the following command:$ IMAGEID=$(cat < "./${BUILDID}-container.tar" | sudo podman load | grep -o -P '(?<=sha256[@:])[a-z0-9]*')Use the
IMAGEIDvariable result to run the Podman command step by running the following command:$ sudo podman run -d --name=minimal-microshift-server -p 8085:8080 ${IMAGEID}This command also returns the ID of the container saved in the
IMAGEIDvariable for monitoring.
Generate the installation program blueprint file by running the following command:
cat > microshift-installer.toml <<EOF name = "microshift-installer" description = "" version = "0.0.0" modules = [] groups = [] packages = [] EOF
1.8. Add the blueprint to image builder and build the ISO Copy linkLink copied to clipboard!
You must add the blueprint to an image builder to build the ISO.
Procedure
Add the blueprint to the image builder by running the following command:
$ sudo composer-cli blueprints push microshift-installer.tomlStart the
ostreeISO build by running the following command:$ BUILDID=$(sudo composer-cli compose start-ostree --url http://localhost:8085/repo/ --ref "rhel/9/$(uname -m)/edge" microshift-installer edge-installer | awk '{print $2}')This command also returns the identification (ID) of the build for monitoring.
You can check the status of the build periodically by running the following command:
$ sudo composer-cli compose statusExample output for a running build
ID Status Time Blueprint Version Type Size c793c24f-ca2c-4c79-b5b7-ba36f5078e8d RUNNING Wed Jun 7 13:22:20 2023 microshift-installer 0.0.0 edge-installerExample output for a completed build
ID Status Time Blueprint Version Type Size c793c24f-ca2c-4c79-b5b7-ba36f5078e8d FINISHED Wed Jun 7 13:34:49 2023 microshift-installer 0.0.0 edge-installer
1.9. Download the ISO and prepare it for use Copy linkLink copied to clipboard!
After creating the ISO, you must download it and prepare it for use.
Procedure
Download the ISO using the ID by running the following command:
$ sudo composer-cli compose image ${BUILDID}Change the ownership of the downloaded container image to the current user by running the following command:
$ sudo chown $(whoami). ${BUILDID}-installer.isoAdd read permissions for the current user to the image by running the following command:
$ sudo chmod a+r ${BUILDID}-installer.iso
Next steps
- Provision a virtual machine with a Kickstart file.
1.9.1. Embedding a Kickstart file in an ISO Copy linkLink copied to clipboard!
You can use the Kickstart file provided with MicroShift, or you can update an existing RHEL for Edge Installer (ISO) Kickstart file.
When ready, embed the Kickstart file into the ISO. Your Kickstart file must include detailed instructions about how to create a user and how to fetch and deploy the RHEL for Edge image.
Prerequisites
- You created a RHEL for Edge Installer (ISO) image containing your RHEL for Edge commit with MicroShift.
-
You have an existing Kickstart file ready for updating. You can use the
microshift-starter.ksKickstart file provided with the MicroShift RPMs.
Procedure
In the main section of the Kickstart file, update the setup of the filesystem such that it contains an LVM volume group called
rhelwith at least 10GB system root. Leave free space for the LVMS CSI driver to use for storing the data for your workloads.Example Kickstart file snippet for configuring the filesystem
# Partition disk such that it contains an LVM volume group called `rhel` with a # 10GB+ system root but leaving free space for the LVMS CSI driver for storing data. # # For example, a 20GB disk would be partitioned in the following way: # # NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT # sda 8:0 0 20G 0 disk # ├─sda1 8:1 0 200M 0 part /boot/efi # ├─sda1 8:1 0 800M 0 part /boot # └─sda2 8:2 0 19G 0 part # └─rhel-root 253:0 0 10G 0 lvm /sysroot # ostreesetup --nogpg --osname=rhel --remote=edge \ --url=file:///run/install/repo/ostree/repo --ref=rhel/<RHEL VERSION NUMBER>/x86_64/edge zerombr clearpart --all --initlabel part /boot/efi --fstype=efi --size=200 part /boot --fstype=xfs --asprimary --size=800 # Uncomment this line to add a SWAP partition of the recommended size #part swap --fstype=swap --recommended part pv.01 --grow volgroup rhel pv.01 logvol / --vgname=rhel --fstype=xfs --size=10000 --name=root # To add users, use a line such as the following user --name=<YOUR_USER_NAME> \ --password=<YOUR_HASHED_PASSWORD> \ --iscrypted --groups=<YOUR_USER_GROUPS>In the
%postsection of the Kickstart file, add your pull secret and the mandatory firewall rules.Example Kickstart file snippet for adding the pull secret and firewall rules
%post --log=/var/log/anaconda/post-install.log --erroronfail # Add the pull secret to CRI-O and set root user-only read/write permissions cat > /etc/crio/openshift-pull-secret << EOF YOUR_OPENSHIFT_PULL_SECRET_HERE EOF chmod 600 /etc/crio/openshift-pull-secret # Configure the firewall with the mandatory rules for MicroShift firewall-offline-cmd --zone=trusted --add-source=10.42.0.0/16 firewall-offline-cmd --zone=trusted --add-source=169.254.169.1 %endInstall the
mkksisotool by running the following command:$ sudo yum install -y loraxUpdate the ISO with your new Kickstart file by running the following command:
$ sudo mkksiso <your_kickstart>.ks <your_installer>.iso <updated_installer>.iso