Installing with image mode for RHEL
Embedding MicroShift in a bootc image
Abstract
Chapter 1. Understanding image mode for RHEL with MicroShift Copy linkLink copied to clipboard!
You can embed MicroShift into an operating system image using image mode for Red Hat Enterprise Linux (RHEL).
1.1. About image mode for Red Hat Enterprise Linux (RHEL) Copy linkLink copied to clipboard!
By using image mode for RHEL, you can use the same tools and techniques for the operating system that you use with application containers. Image mode for RHEL is a deployment method that uses a container-native approach to build, deploy, and manage the operating system as a rhel-bootc image.
- This container image uses standard OCI or Docker containers as a transport and delivery format for base operating system updates.
- A bootc image includes a Linux kernel that is used to start the operating system.
- By using bootc containers, developers, operations administrators, and solution providers can all use the same container-native tools and techniques.
Image mode for RHEL splits the creation and installation of software changes into two steps: one on a build system and one on a running target system.
- In the build-system step, a Podman build inspects the RPM files available for installation, determines any dependencies, and creates an ordered list of chained steps to complete. Along with any other system configuration steps taking place, the end result is a new operating system available to install.
- In the running-target-system step, a bootc update downloads, unpacks, and prepares the new operating system to be started alongside the currently running system. Local configuration changes are carried forward to the new operating system. These changes take effect only when the system is restarted and the new operating system image replaces the previously running one.
1.2. Preparing for bootc image building Copy linkLink copied to clipboard!
Use the image builder tool to compose customized MicroShift bootc images optimized for edge deployments. You can run a MicroShift node with your applications on a image mode for RHEL 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 image mode for RHEL:
Follow the instructions at the following link:
For offline or disconnected configurations, embed all container image dependencies as part of the system image. When container images are downloaded without being embedded into the system image, CRI-O wipes them off during unclean shutdowns, such as when a power loss occurs. In this case, you can only restore those container images when the system is online.
1.3. Additional resources Copy linkLink copied to clipboard!
Chapter 2. Installing and publishing a bootc image to a registry Copy linkLink copied to clipboard!
MicroShift is built and published as image mode containers. When installing a Red Hat Enterprise Linux (RHEL) bootable container image with MicroShift, use either a prebuilt bootable container image or build your own custom bootable container image.
2.1. The image mode for RHEL with MicroShift workflow Copy linkLink copied to clipboard!
Before you use image mode for RHEL, ensure that the following resources are available:
- A RHEL 9.6 host with an active Red Hat subscription for building MicroShift bootc images.
-
A remote registry for storing and accessing
rhel-bootcimages. - An AArch64 or x86_64 system architecture.
The workflow for using image mode for RHEL with MicroShift includes the following steps:
- Find and use a prebuilt MicroShift container image to install RHEL.
- If the prebuilt MicroShift container image requires customization, build a custom MicroShift container image.
- Run the container image.
The rpm-ostree file system used by RHEL for Edge is not supported in image mode for RHEL. Do not use the rpm-ostree file system to modify deployments that use image mode for RHEL.
2.2. Get or build your bootc image Copy linkLink copied to clipboard!
Either get an existing bootc image or create one, then you can publish that image to a remote registry for use.
2.2.1. Getting the published bootc image for MicroShift Copy linkLink copied to clipboard!
You can use the MicroShift container images to install image mode for RHEL.
Prerequisites
- You have an x86_64 or AArch64 platform.
-
You have access to the
registry.redhat.ioregistry.
Procedure
- Navigate to the Red Hat Ecosystem Catalog.
-
Search for the MicroShift container image by using the
microshift-bootckeyword. - Open the container image page of the MicroShift container image.
-
Select the
Get this imagetab to view instructions for downloading the image. Get access to the latest image on x86_64 and AArch64 platforms by logging into the registry using the following command:
sudo podman login registry.redhat.io
$ sudo podman login registry.redhat.ioCopy to Clipboard Copied! Toggle word wrap Toggle overflow Download the bootc image by running the following command:
podman pull registry.redhat.io/openshift4/microshift-bootc-rhel9:v4.19
$ podman pull registry.redhat.io/openshift4/microshift-bootc-rhel9:v4.19Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.2. Building the bootc image Copy linkLink copied to clipboard!
Build your Red Hat Enterprise Linux (RHEL) that contains MicroShift as a bootable container image by using a Containerfile.
Prerequisites
- A RHEL 9.6 host with an active Red Hat subscription for building MicroShift bootc images and running containers.
-
You logged into the RHEL 9.6 host by using the user credentials that have
sudopermissions. -
The
rhocpandfast-datapathrepositories are accessible in the host subscription. The repositories do not necessarily need to be enabled on the host. - You have a remote registry such as {quay} for storing and accessing bootc images.
-
You used the
dnf install -y container-toolscommand to install thecontainer-toolsmeta-package on the host. The meta-package contains all container tools, such as Podman, Buildah, and Skopeo for additional support and troubleshooting. These tools are required for obtaining assistance from Red Hat Support when you are building and installing the image.
Procedure
Create a Containerfile that includes the following instructions:
Example Containerfile for RHEL image mode
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Podman uses the host subscription information and repositories inside the container when building the container image. If the rhocp and fast-datapath repositories are not available on the host, the build fails.
Set the
PULL_SECRETenvironment variable:PULL_SECRET=~/.pull-secret.json
$ PULL_SECRET=~/.pull-secret.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
USER_PASSWDenvironment variable:USER_PASSWD=<redhat_user_password>
$ USER_PASSWD=<redhat_user_password>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <redhat_user_password> with your password.
Configure the
IMAGE_NAMEenvironment variable:IMAGE_NAME=microshift-4.19-bootc
$ IMAGE_NAME=microshift-4.19-bootcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a local bootc image by running the following image build command:
sudo podman build --authfile "${PULL_SECRET}" -t "${IMAGE_NAME}" \ --build-arg USER_PASSWD="${USER_PASSWD}" \ -f Containerfile$ sudo podman build --authfile "${PULL_SECRET}" -t "${IMAGE_NAME}" \ --build-arg USER_PASSWD="${USER_PASSWD}" \ -f ContainerfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantHow secrets are used during the image build:
-
The podman
--authfileargument is required to pull the baserhel-bootc:9.6image from theregistry.redhat.ioregistry. -
The build
USER_PASSWDargument is used to set a password for theredhatuser.
-
The podman
Verification
Verify that the local MicroShift bootc image was created by running the following command:
sudo podman images "${IMAGE_NAME}"$ sudo podman images "${IMAGE_NAME}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
REPOSITORY TAG IMAGE ID CREATED SIZE localhost/microshift-4.19-bootc latest 193425283c00 2 minutes ago 2.31 GB
REPOSITORY TAG IMAGE ID CREATED SIZE localhost/microshift-4.19-bootc latest 193425283c00 2 minutes ago 2.31 GBCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Publishing the bootc image to the remote registry Copy linkLink copied to clipboard!
Publish your bootc image to the remote registry so that the image can be used for running the container on another host, or for when you want to install a new operating system with the bootc image layer.
Prerequisites
-
You are logged in to the RHEL 9.6 host where the image was built using the user credentials that have
sudopermissions. - You have a remote registry such as {quay} for storing and accessing bootc images.
- You created the Containerfile and built the image.
Procedure
Set the
REGISTRY_URLvariable for the image by running the following command:REGISTRY_URL=<quay.io>
$ REGISTRY_URL=<quay.io>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <quay.io> with the URL for your image registry.
Log in to your remote registry by running the following command:
sudo podman login "${REGISTRY_URL}"$ sudo podman login "${REGISTRY_URL}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
IMAGE_NAMEvariable for the image by running the following command:IMAGE_NAME=<microshift-4.19-bootc>
$ IMAGE_NAME=<microshift-4.19-bootc>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <microshift-4.19-bootc> with the name of the image you want to publish.
Set the
REGISTRY_IMGvariable for the image by running the following command:REGISTRY_IMG=<myorg/mypath>/"${IMAGE_NAME}"$ REGISTRY_IMG=<myorg/mypath>/"${IMAGE_NAME}"1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <myorg/mypath> with your remote registry organization name and path.
Publish the image by running the following command:
sudo podman push localhost/"${IMAGE_NAME}" "${REGISTRY_URL}/${REGISTRY_IMG}"$ sudo podman push localhost/"${IMAGE_NAME}" "${REGISTRY_URL}/${REGISTRY_IMG}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
- Run the container using the image you pushed to your registry as described in the "Running the MicroShift bootc container" section.
Chapter 3. Running the bootc image in a virtual machine Copy linkLink copied to clipboard!
Use the bootable container image as an installation source to set up a Red Hat Enterprise Linux (RHEL) virtual machine.
3.1. Creating the Kickstart file Copy linkLink copied to clipboard!
You must create the Kickstart file to use during installation.
Prerequisites
- You have root-user access.
- You are logged in to the physical hypervisor host.
Procedure
Set the
AUTH_CONFIGenvironment variable to reference the secret file in thekickstart.ksfile to authenticate private container registry access by running the following command:AUTH_CONFIG=~/.quay-auth.json
$ AUTH_CONFIG=~/.quay-auth.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
PULL_SECRETenvironment variable to reference the secret files in thekickstart.ksfile to authenticate the OpenShift Container Platform registry access by running the following command:PULL_SECRET=~/.pull-secret.json
$ PULL_SECRET=~/.pull-secret.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
IMAGE_REFenvironment variable to reference the image mode for your container image to use during installation by running the following command:IMAGE_REF="quay.io/<myorg>/<mypath>/microshift-4.19-bootc"
$ IMAGE_REF="quay.io/<myorg>/<mypath>/microshift-4.19-bootc"1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace <myorg/<mypath> with your remote registry organization name and path.
Create the
kickstart.ksfile to use during installation by running the following script:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Creating a virtual machine Copy linkLink copied to clipboard!
You can create a virtual machine by using the Red Hat Enterprise Linux (RHEL) boot ISO image.
Prerequisites
- You created the Kickstart file.
-
You installed the OpenShift CLI (
oc). -
You have
redhatcredentials.
Procedure
- Download the Red Hat Enterprise Linux (RHEL) boot ISO image from the Download Red Hat Enterprise Linux.
-
Copy the downloaded file to the
/var/lib/libvirt/imagesdirectory. Configure the VMNAME environment variable with your value by running the following command:
VMNAME=microshift-4.19-bootc
$ VMNAME=microshift-4.19-bootcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the NETNAME environment variable with your value by running the following command:
NETNAME=default
$ NETNAME=defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a RHEL virtual machine with 2 cores, 2GB of RAM and 20GB of storage by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
sudo virt-installcommand uses the Kickstart file to pull a bootc image from the remote registry and install the RHEL operating system.-
Log in to the virtual machine by using your
redhatcredentials.
Verification
Verify that all of the MicroShift pods are running without error by entering the following command:
watch sudo oc get pods -A \ --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig$ watch sudo oc get pods -A \ --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfigCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. Creating a fully self-contained bootc image Copy linkLink copied to clipboard!
If you need your bootc image to include everything required to run workloads, use physically-bound container images. Edge-computing scenarios involving embedded systems on specialized devices, high security, or high hardware control scenarios are likely candidates.
4.1. About physically bound bootc image building Copy linkLink copied to clipboard!
When a bootc image is fully self-contained, everything you need to run workloads is embedded with the bootc image, including MicroShift and application container images. The underlying mechanism is to pre-pull physically-bound images during image build and then make them available at runtime.
Because embedded images might change with each system update, you cannot pull the images directly to the default container storage. Additional image stores do not work in this case because of current implementation limits. These limits do not allow bootc image updates for those container images.
The manifest, layer tarballs, and signatures are exported as individual files into the directory. The dir transport type preserves the digest of the image, which is crucial for the original digest to reference the image.
Technical details to understand include the following items:
- Each image goes into the same top-level directory, but a separate subdirectory.
-
Subdirectories are named after the image reference string
SHA. -
An image list file maps image references to their name
SHA. -
You must install the
microshift-release-infoRPM to get the image references required by MicroShift. - You must have image references for your workloads. Apply the same methods to workload image references that you use for MicroShift image references.
-
When you build the container, you must install the
microshift-release-infoRPM. Therelease-x86_64.jsonandrelease-aarch64.jsonfiles from this RPM reside in the/usr/share/microshift/release/directory. These files contain image references required by MicroShift.
You must keep track of the name of the image. A tag, digest, or a mix of both can reference images. Choosing the best way to reference the images you need can impact the quality and robustness of workloads.
4.2. Embedding container images into a bootc image Copy linkLink copied to clipboard!
First, you must add instructions to an existing Containerfile to copy the images you want and list them in a file to keep track of the copied image names. Then, you must copy images locally from the /usr/lib/containers/storage directory to the local container storage.
You cannot store images in the default or additional container storage directory when you build bootc images. For example, if you update the additional container store setting in /etc/containers/storage.conf to point to the /usr/lib/containers/storage directory, bootc image updates fail.
Prerequisites
- You have root access to the host.
- You installed Podman.
- You installed skopeo.
- You have workload image references.
- You have a Containerfile for building MicroShift images.
Procedure
Add the pull secret to the container build procedure to ensure that images can be pulled by running the following command:
podman build --secret id=pullsecret,src=/<path/to/pull/secret>.json
$ podman build --secret id=pullsecret,src=/<path/to/pull/secret>.json1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the path to your pull secret in <path/to/pull/secret>.
Add the instructions to physically embed the image at build time by adding the following to your Containerfile:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow When run, the Containerfile extracts the list of MicroShift container image dependencies from the
microshift-release-infoRPM and pulls them into a custom/usr/lib/containers/storagedirectory. The resulting image list file is saved at/usr/lib/containers/storage/image-list.txt.Next, you must copy container images from the custom directory to the main container storage directory so that they are available to MicroShift. Add a script and a systemd service to your Containerfile to copy the embedded images from the
/usr/lib/containers/storagedirectory to the local container storage. Copying happens at runtime before each MicroShift start. Use the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
- Build the image.
- Test and deploy per your use case.