Build for specific target platforms

You can produce platform-specific disk image formats (ISO, VMDK, QCOW2) by using either the simplified image building workflow or the advanced process described here. In the simplified workflow, select the desired format when creating the build.

About this task

For optimized provisioning and integration with Red Hat OpenShift Virtualization and VMware vSphere, you can provide enrollment certificates and agent configurations by using the cloud-init utility rather than embedding them in the image. You can also include appropriate guest tools for better platform integration. This process generates platform-specific image formats, such as QCOW2 for Red Hat OpenShift Virtualization and VMDK for vSphere.

Building images for Red Hat OpenShift Virtualization

When building operating system images and disk images for Red Hat OpenShift Virtualization, you can follow the Building a _bootc operating system image for the Red Hat Edge Manager_ process with the following changes:

  • Use late binding by injecting the enrollment certificate or the agent configuration through cloud-init when provisioning the virtual device.
  • Add the qemu-guest-agent package to the image and enable the QEMU guest agent service.
  • Build a disk image of type qcow2 instead of iso.
Note

You must build the operating system image on a Red Hat Enterprise Linux host that has the required Red Hat Edge Manager subscription entitlement so that you can enable the edge-manager-<version> repository.

Complete the generic steps with changes to the following steps:

Procedure

  1. Build a RHEL 9 operating system image that includes the Red Hat Edge Manager agent and the QEMU guest agent, but excludes the agent configuration.
  2. Create a file named Containerfile with the following content. Replace required_os_version, edge-manager-<version>, and rhel-<version> with the values for your environment:
    FROM registry.redhat.io/rhel9/rhel-bootc:<required_os_version>
    
    RUN dnf config-manager --set-enabled edge-manager-<version>-for-rhel-<version>-$(uname -m)-rpms && \
        dnf -y install flightctl-agent && \
        dnf -y clean all && \
        systemctl enable flightctl-agent.service
    
    RUN dnf -y install cloud-init qemu-guest-agent && \
        dnf -y clean all && \
        ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants && \
        systemctl enable qemu-guest-agent.service
  3. Optional: To enable podman-compose application support, add the following section to the Containerfile file:
    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.service

    Build, sign, and publish the bootc operating system image by following the generic image building process.

  4. Create a directory called output by running the following command:
    mkdir -p output
  5. Generate an operating system disk image of type qcow2 from your operating system image by running the following command:
    sudo podman run --rm -it --privileged --pull=newer \
        --security-opt label=type:unconfined_t \
        -v "${PWD}/output":/output \
        -v /var/lib/containers/storage:/var/lib/containers/storage \
        registry.redhat.io/rhel9/bootc-image-builder:latest \
        --type qcow2 \
        ${OCI_IMAGE_REPO}:${OCI_IMAGE_TAG}

    When bootc-image-builder completes, you can find the disk image in the ${PWD}/output/qcow2/disk.qcow2 path.

    Red Hat OpenShift Virtualization can download disk images from an Open Container Initiative (OCI) registry, but it uses a container disk image instead of an OCI artifact.

    Complete the following steps to build, sign, and upload the QCOW2 disk image:

  6. Create a file that is named Containerfile.qcow2 with 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/
  7. Build, sign, and publish your disk image. Run 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}

    Building images for VMware vSphere

    When building operating system images and disk images for VMware vSphere, you can follow the Building a _bootc operating system image for the Red Hat Edge Manager_ process with the following changes:

    • Use late binding by injecting the enrollment certificate or the agent configuration through cloud-init when provisioning the virtual device.
    • Add the open-vm-tools guest tools to the image.
    • Build a disk image of type vmdk instead of iso.

      Build a RHEL 9 operating system image that includes the Red Hat Edge Manager agent and VM guest tools, but excludes the agent configuration.

      Note

      You must build the operating system image on a Red Hat Enterprise Linux host that has the required Red Hat Edge Manager subscription entitlement so that you can enable the edge-manager-<version> repository.

      Complete the generic steps with changes to the following steps:

  8. Create a file that is named Containerfile with the following content. Replace required_os_version, edge-manager-<version>, and rhel-<version> with the values for your environment:
    FROM registry.redhat.io/rhel9/rhel-bootc:<required_os_version>
    
    RUN dnf config-manager --set-enabled edge-manager-<version>-for-rhel-<version>-$(uname -m)-rpms && \
        dnf -y install flightctl-agent && \
        dnf -y clean all && \
        systemctl enable flightctl-agent.service
    
    RUN dnf -y install cloud-init open-vm-tools && \
        dnf -y clean all && \
        ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants && \
        systemctl enable vmtoolsd.service
  9. Create a directory named output by running the following command:
    mkdir -p output
  10. Generate an operating system disk image of type vmdk from your operating system image by running the following command:
    sudo podman run --rm -it --privileged --pull=newer \
        --security-opt label=type:unconfined_t \
        -v "${PWD}/output":/output \
        -v /var/lib/containers/storage:/var/lib/containers/storage \
        registry.redhat.io/rhel9/bootc-image-builder:latest \
        --type vmdk \
        ${OCI_IMAGE_REPO}:${OCI_IMAGE_TAG}

    When bootc-image-builder completes, you can find the disk image in the ${PWD}/output/vmdk/disk.vmdk path.

    Additional resources