Chapter 4. Operating system images for using with the Red Hat Edge Manager
Image-based operating systems allow the operating system and its configuration and applications to be versioned, deployed, and updated as a single unit. Using an image-based operating system reduces operational risks by doing the following:
- Minimizing potential drift between what is tested and what is deployed to a large number of devices.
- Minimizing the risk of failed updates that require expensive maintenance or replacement through transactional updates and rollbacks.
The Red Hat Edge Manager focuses on image-based Linux operating systems that run bootable container images (bootc).
For more information, see bootc.
The bootc tool does not update package-based operating systems.
4.1. The image building process Copy linkLink copied to clipboard!
-
Choose a base
bootcoperating system image, such as a Fedora, CentOS, or RHEL image. Create a container file that layers the following items onto the base
bootcimage:- The Red Hat Edge Manager agent and configuration.
- Optional: Any drivers specific to your target deployment environment.
- Optional: Host configuration, for example, certificate authority bundles, and application workloads that are common to all deployments.
-
Build, publish, and sign a
bootcoperating system image usingpodmanandskopeo. -
Create an operating system disk image by using
bootc-image-builder. -
Build, publish, and sign an operating system disk image using
skopeo.
The operating system disk image has partitions, volumes, the file system, and the initial bootc image. You only need to create the operating system disk image once, during provisioning. For later device updates, you only need the bootc operating system image, which has the files in the file system.
4.2. Special considerations for building images Copy linkLink copied to clipboard!
4.2.1. Build-time configuration over dynamic runtime configuration Copy linkLink copied to clipboard!
Add the configuration to the operating system image at build time. Adding the configuration at build time ensures that the configurations are tested, distributed, and updated together. In cases when build-time configuration is not feasible or desirable, you can dynamically configure devices at runtime instead with the Red Hat Edge Manager.
Dynamic runtime configuration is preferable in the following cases:
- You have a configuration that is deployment or site-specific, such as a hostname or a site-specific network credential.
- You have secrets that are not secure to distribute with the image.
- You have application workloads that need to be added, updated, or deleted without reboot or they are on a faster cadence than the operating system.
4.2.2. Configuration in the /usr directory Copy linkLink copied to clipboard!
Place configuration files in the /usr directory if the configuration is static and the application or service supports that configuration. By placing the configuration in the /usr directory, the configuration remains read-only and fully defined by the image.
Do not place the configuration in the /usr directory in the following cases:
- The configuration is deployment or site-specific.
-
The application or service only supports reading configuration from the
/etcdirectory. - The configuration might need to be changed at runtime.
4.2.3. Drop-in directories Copy linkLink copied to clipboard!
Use drop-in directories to add, replace, or remove configuration files that the service aggregates. Do not directly edit your configuration files because it can cause deviations from the target configuration.
You can identify drop-in directories by the .d/ at the end of the directory name. For example, /etc/containers/certs.d, /etc/cron.d, and /etc/NetworkManager/conf.d.
4.2.4. Operating system images with scripts Copy linkLink copied to clipboard!
Avoid executing scripts or commands that change the file system. The bootc or the Red Hat Edge Manager can overwrite the changed files which can cause a deviation or failed integrity checks..
Instead, run such scripts or commands during image building so changes are part of the image. You can also use the configuration management mechanisms of the Red Hat Edge Manager.
Additional resources
4.3. Building a bootc operating system image for the Red Hat Edge Manager Copy linkLink copied to clipboard!
To prepare your device to be managed by the Red Hat Edge Manager, build a bootc operating system image that has the Red Hat Edge Manager agent. Then build an operating system disk image for your devices.
For more information, see the following sections:
- Installing the Red Hat Edge Manager CLI
- Optional: Requesting an enrollment certificate for early binding
- Optional: Using image pull secrets
- Building the operating system image with bootc
- Signing and publishing the bootc operating system image by using Sigstore
- Building the operating system disk image
- Optional: Signing and publishing the operating system disk image to an Open Container Initiative registry
4.3.1. Prerequisites Copy linkLink copied to clipboard!
See the following prerequisites for building a bootc operating system image:
-
Install
podmanversion 5.0 or later andskopeoversion 1.14 or later. See Getting container tools. -
Install
bootc-image-builder. See Installing bootc-image-builder.
4.3.2. Installing the Red Hat Edge Manager CLI Copy linkLink copied to clipboard!
To install the Red Hat Edge Manager CLI, complete the following steps:
Procedure
Enable the subscription manager for the repository appropriate for your system by running the following command:
sudo subscription-manager repos --enable ansible-automation-platform-2.5-for-rhel-9-x86_64-rpms
sudo subscription-manager repos --enable ansible-automation-platform-2.5-for-rhel-9-x86_64-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For a full list of available repositories for the Red Hat Edge Manager, see the Additional resources section.
Install the
flightctlCLI with your package manager by running the following command:sudo dnf install flightctl
sudo dnf install flightctlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If you set up the OAuth application manually, you also need to make sure that one utility xdg-open, x-www-browser, or www-browser is available, for example, by installing xdg-utils.
4.3.3. Logging into the Red Hat Edge Manager through the CLI Copy linkLink copied to clipboard!
How you log in the Red Hat Edge Manager depends on whether you choose the automatic or manual method when you initially set up the application.
Procedure
If you use the automatic setup you can create a personal access token, even only with Read scope (under the profile icon in the top right corner of your Ansible Automation Platform UI > User details > Tokens tab) and then use this token to log in directly through the CLI, with the following example syntax:
flightctl login https://<your-edge-manager-ip-or-domain>:3443 --token=<your-aap-oauth-token> --insecure-skip-tls-verify
flightctl login https://<your-edge-manager-ip-or-domain>:3443 --token=<your-aap-oauth-token> --insecure-skip-tls-verifyCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you use the manual setup, use the Client ID to log in through a web-based process, with the following example syntax:
flightctl login https://<your-edge-manager-ip-or-domain>:3443 --web --client-id=<your-aap-client-id> --insecure-skip-tls-verify
flightctl login https://<your-edge-manager-ip-or-domain>:3443 --web --client-id=<your-aap-client-id> --insecure-skip-tls-verifyCopy to Clipboard Copied! Toggle word wrap Toggle overflow This opens in a web browser and asks you to approve.
The
--insecure-skip-tls-verifyparameter is used only if you have not generated your own valid certificates.
Next steps
Use the following commands to help you with the CLI:
To output a list of available commands, use:
flightctl
flightctlCopy to Clipboard Copied! Toggle word wrap Toggle overflow To output both the flightctl CLI version and the back-end Red Hat Edge Manager version, use:
flightctl version
flightctl versionCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To ensure supportability and proper functionality, the version of the flightctl CLI must match the version of the Red Hat Edge Manager in use. Mismatched versions are not supported.
4.3.4. Optional: Requesting an enrollment certificate for early binding Copy linkLink copied to clipboard!
If you want to include an agent configuration in the image, complete the following steps:
Procedure
Log in to the flightctl CLI by following the steps in Logging into the Red Hat Edge Manager through the CLI.
NoteThe CLI uses the certificate authority pool of the host to verify the identity of the Red Hat Edge Manager service. The verification can lead to a TLS verification error when using self-signed certificates, if you do not add your certificate authority certificate to the pool. You can bypass the server verification by adding the
--insecure-skip-tls-verifyflag to your command.Get the enrollment credentials in the format of an agent configuration file by running the following command:
flightctl certificate request --signer=enrollment --expiration=365d --output=embedded > config.yaml
flightctl certificate request --signer=enrollment --expiration=365d --output=embedded > config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note-
The
--expiration=365doption specifies that the credentials are valid for a year. -
The
--output=embeddedoption specifies that the output is an agent configuration file with the enrollment credentials embedded.
The returned
config.yamlcontains the URLs of the Red Hat Edge Manager service, the certificate authority bundle, and the enrollment client certificate and key for the agent. See the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
The
4.3.5. Optional: Using image pull secrets Copy linkLink copied to clipboard!
If your device relies on containers from a private repository, you must configure a pull secret for the registry. Complete the following steps:
Procedure
Depending on the kind of container image you use, place the pull secret in one or both of the following system paths on the device:
-
Operating system images use the
/etc/ostree/auth.jsonpath. Application container images use the
/root/.config/containers/auth.jsonpath.ImportantThe pull secret must exist on the device before the secret can be consumed.
-
Operating system images use the
Ensure that the pull secrets use the following format:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information, see the Additional resources section.
4.3.6. Building the operating system image with bootc Copy linkLink copied to clipboard!
Build the operating system image with the bootc that contains the Red Hat Edge Manager agent. You can optionally include the following items in your operating system image:
- The agent configuration for early binding
- Any drivers
- Host configuration
- Application workloads that you need
Complete the following steps:
Procedure
Create a
Containerfilefile with the following content to build a RHEL 9-based operating system image that includes the Red Hat Edge Manager agent and configuration:FROM registry.redhat.io/rhel9/rhel-bootc:<required_os_version> RUN dnf --enablerepo ansible-automation-platform-2.5-for-rhel-9-x86_64-rpms -y install flightctl-agent-0.7.2-1.el9fc && \ dnf -y clean all && \ systemctl enable flightctl-agent.service && \ systemctl mask bootc-fetch-apply-updates.timerFROM registry.redhat.io/rhel9/rhel-bootc:<required_os_version>1 RUN dnf --enablerepo ansible-automation-platform-2.5-for-rhel-9-x86_64-rpms -y install flightctl-agent-0.7.2-1.el9fc && \ dnf -y clean all && \ systemctl enable flightctl-agent.service && \ systemctl mask bootc-fetch-apply-updates.timer2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf your device relies on containers from a private repository, you must place the device pull secret in the
/etc/ostree/auth.jsonpath. The pull secret must exist on the device before the secret can be consumed.Optional: To enable
podman-composeapplication support, add the following section to theContainerfilefile:RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ dnf -y install podman-compose && \ dnf -y clean all && \ systemctl enable podman.serviceRUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ dnf -y install podman-compose && \ dnf -y clean all && \ systemctl enable podman.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: If you created the
config.yamlfor early binding, add the following section to theContainerfile:ADD config.yaml /etc/flightctl/
ADD config.yaml /etc/flightctl/Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information, see Optional: Requesting an enrollment certificate for early binding.
Define the Open Container Initiative (OCI) registry by running the following command:
OCI_REGISTRY=registry.redhat.io
OCI_REGISTRY=registry.redhat.ioCopy to Clipboard Copied! Toggle word wrap Toggle overflow Define the image repository that you have permissions to write to by running the following command:
OCI_IMAGE_REPO=${OCI_REGISTRY}/<your_org>/<your_image>OCI_IMAGE_REPO=${OCI_REGISTRY}/<your_org>/<your_image>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the image tag by running the following command:
OCI_IMAGE_TAG=v1
OCI_IMAGE_TAG=v1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Build the operating system image for your target platform:
sudo podman build -t ${OCI_IMAGE_REPO}:${OCI_IMAGE_TAG} .sudo podman build -t ${OCI_IMAGE_REPO}:${OCI_IMAGE_TAG} .Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3.7. Signing and publishing the bootc operating system image by using Sigstore Copy linkLink copied to clipboard!
To sign the bootc operating system image by using Sigstore, complete the following steps:
Procedure
Generate a Sigstore key pair named
signingkey.pubandsigningkey.private:skopeo generate-sigstore-key --output-prefix signingkey
skopeo generate-sigstore-key --output-prefix signingkeyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure container tools such as Podman and Skopeo to upload Sigstore signatures together with your signed image to your OCI registry:
sudo tee "/etc/containers/registries.d/${OCI_REGISTRY}.yaml" > /dev/null <<EOF docker: ${OCI_REGISTRY}: use-sigstore-attachments: true EOFsudo tee "/etc/containers/registries.d/${OCI_REGISTRY}.yaml" > /dev/null <<EOF docker: ${OCI_REGISTRY}: use-sigstore-attachments: true EOFCopy to Clipboard Copied! Toggle word wrap Toggle overflow Log in to your OCI registry by running the following command:
sudo podman login ${OCI_REGISTRY}sudo podman login ${OCI_REGISTRY}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sign and publish the operating system image by running the following command:
sudo podman push \ --sign-by-sigstore-private-key ./signingkey.private \ ${OCI_IMAGE_REPO}:${OCI_IMAGE_TAG}sudo podman push \ --sign-by-sigstore-private-key ./signingkey.private \ ${OCI_IMAGE_REPO}:${OCI_IMAGE_TAG}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3.8. Building the operating system disk image Copy linkLink copied to clipboard!
Build the operating system disk image that contains the file system for your devices.
Complete the following steps:
Procedure
Create a directory called
outputby running the following command:mkdir -p output
mkdir -p outputCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use
bootc-image-builderto generate an operating system disk image of typeisofrom your operating system image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
When the bootc-image-builder completes, you can find the ISO disk image at the ${PWD}/output/bootiso/install.iso path.
4.3.9. Optional: Signing and publishing the operating system disk image to an Open Container Initiative registry Copy linkLink copied to clipboard!
Sign and publish your disk image to your Open Container Initiative (OCI) registry. Optionally, you can compress and publish the disk image as an OCI artifact to the same OCI registry as your bootc images, which facilitates a unified hosting and distribution of bootc and disk images. To publish your ISO disk image to a repository named after your bootc image with /diskimage-iso appended.
Prerequisites
- You created a private key by using Sigstore. See Signing and publishing the bootc operating system image by using Sigstore.
Sign and publish your disk image to your OCI registry by completing the following steps:
Procedure
Change the owner of the directory where the ISO disk image is located from
rootto your current user by running the following command:sudo chown -R $(whoami):$(whoami) "${PWD}/output"sudo chown -R $(whoami):$(whoami) "${PWD}/output"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
OCI_DISK_IMAGE_REPOenvironmental variable to be the same repository as yourbootcimage with/diskimage-isoappended by running the following command:OCI_DISK_IMAGE_REPO=${OCI_IMAGE_REPO}/diskimage-isoOCI_DISK_IMAGE_REPO=${OCI_IMAGE_REPO}/diskimage-isoCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a manifest list by running the following command:
sudo podman manifest create \ ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG}sudo podman manifest create \ ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the ISO disk image to the manifest list as an OCI artifact by running the following command:
sudo podman manifest add \ --artifact --artifact-type application/vnd.diskimage.iso \ --arch=amd64 --os=linux \ ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG} \ "${PWD}/output/bootiso/install.iso"sudo podman manifest add \ --artifact --artifact-type application/vnd.diskimage.iso \ --arch=amd64 --os=linux \ ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG} \ "${PWD}/output/bootiso/install.iso"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sign the manifest list with your private Sigstore key and push the image to the registry by running the following command:
sudo podman manifest push --all \ --sign-by-sigstore-private-key ./signingkey.private \ ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG} \ docker://${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG}sudo podman manifest push --all \ --sign-by-sigstore-private-key ./signingkey.private \ ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG} \ docker://${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3.10. Additional resources Copy linkLink copied to clipboard!
- For more information about building the operating system image on different target platforms, see Configuring container pull secrets.
4.3.11. Requirements for specific target platforms Copy linkLink copied to clipboard!
See the following platform considerations:
4.3.11.1. Building images for Red Hat OpenShift Virtualization Copy linkLink copied to clipboard!
When building operating system images and disk images for Red Hat OpenShift Virtualization, you can follow the generic image building process with the following changes:
-
Using late binding by injecting the enrollment certificate or the agent configuration through
cloud-initwhen provisioning the virtual device. -
Adding the
open-vm-toolsguest tools to the image. -
Building a disk image of type
qcow2instead ofiso.
Complete the generic steps with changes to the following steps:
Procedure
- Build an operating system image based on RHEL 9 that includes the Red Hat Edge Manager agent and VM guest tools but excludes the agent configuration.
Create a file named
Containerfilewith the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: To enable
podman-composeapplication support, add the following section to theContainerfilefile:RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ dnf -y install podman-compose && \ dnf -y clean all && \ systemctl enable podman.serviceRUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ dnf -y install podman-compose && \ dnf -y clean all && \ systemctl enable podman.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3.11.2. Building the bootc image Copy linkLink copied to clipboard!
Build, sign, and publish the bootc operating system image by following the generic image building process:
Procedure
Create a directory called
outputby running the following command:mkdir -p output
mkdir -p outputCopy to Clipboard Copied! Toggle word wrap Toggle overflow Generate an operating system disk image of type
vmdkfrom your operating system image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
When the bootc-image-builder completes, you can find the disk image under ${PWD}/output/vmdk/disk.vmdk.
4.3.11.3. Building the QCoW2 disk image Copy linkLink copied to clipboard!
Red Hat OpenShift Virtualization can download disk images from an OCI registry but it expects a container disk image instead of an OCI artifact.
Complete the following steps to build, sign, and upload the QCoW2 disk image:
Procedure
Create a file called
Containerfile.qcow2with the following content:FROM registry.access.redhat.com/ubi9/ubi:latest AS builder ADD --chown=107:107 output/qcow2/disk.qcow2 /disk/ RUN chmod 0440 /disk/* FROM scratch COPY --from=builder /disk/* /disk/
FROM registry.access.redhat.com/ubi9/ubi:latest AS builder ADD --chown=107:107 output/qcow2/disk.qcow2 /disk/1 RUN chmod 0440 /disk/*2 FROM scratch COPY --from=builder /disk/* /disk/3 Copy to Clipboard Copied! Toggle word wrap Toggle overflow Build, sign, and publish your disk image by running the following command:
sudo chown -R $(whoami):$(whoami) "${PWD}/output" OCI_DISK_IMAGE_REPO=${OCI_IMAGE_REPO}/diskimage-qcow2 sudo podman build -t ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG} -f Containerfile.qcow2 . sudo podman push --sign-by-sigstore-private-key ./signingkey.private ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG}sudo chown -R $(whoami):$(whoami) "${PWD}/output" OCI_DISK_IMAGE_REPO=${OCI_IMAGE_REPO}/diskimage-qcow2 sudo podman build -t ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG} -f Containerfile.qcow2 . sudo podman push --sign-by-sigstore-private-key ./signingkey.private ${OCI_DISK_IMAGE_REPO}:${OCI_IMAGE_TAG}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3.11.4. Building images for VMware vSphere Copy linkLink copied to clipboard!
When building operating system images and disk images for VMware vSphere, you can follow the generic image building process with the following changes:
-
Using late binding by injecting the enrollment certificate or the agent configuration through
cloud-initwhen provisioning the virtual device. -
Adding the
open-vm-toolsguest tools to the image. -
Building a disk image of type
vmdkinstead ofiso.
Complete the generic steps with changes to the following steps:
Procedure
- Build an operating system image based on RHEL 9 that includes the Red Hat Edge Manager agent and VM guest tools but excludes the agent configuration.
Create a file named
Containerfilewith the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a directory called
outputby running the following command:mkdir -p output
mkdir -p outputCopy to Clipboard Copied! Toggle word wrap Toggle overflow Generate an operating system disk image of type
vmdkfrom your operating system image by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
When the bootc-image-builder completes, you can find the disk image under ${PWD}/output/vmdk/disk.vmdk.