1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00

CNV-27612: Procedure to build container disk image

This commit is contained in:
Shikha Jhala
2023-04-19 10:05:40 -04:00
committed by openshift-cherrypick-robot
parent b8f2660032
commit e45ad6cd11
2 changed files with 168 additions and 0 deletions

View File

@@ -0,0 +1,164 @@
// Module included in the following assemblies:
//
// * virt//support/monitoring/virt-running-cluster-checkups.adoc
:_content-type: PROCEDURE
[id="virt-building-vm-containerdisk-image_{context}"]
= Building a container disk image for {op-system-base} virtual machines
You can build a custom {op-system-base-full} 8 OS image in `qcow2` format and use it to create a container disk image. You can store the container disk image in a registry that is accessible from your cluster and specify the image location in the `spec.param.vmContainerDiskImage` attribute of the DPDK checkup config map.
To build a container disk image, you must create an image builder virtual machine (VM). The _image builder VM_ is a {op-system-base} 8 VM that can be used to build custom {op-system-base} images.
.Prerequisites
* The image builder VM must run {op-system-base} 8.7 and must have a minimum of 2 CPU cores, 4 GiB RAM, and 20 GB of free space in the `/var` directory.
* You have installed the image builder tool and its CLI (`composer-cli`) on the VM.
* You have installed the `virt-customize` tool:
+
[source,terminal]
----
# dnf install libguestfs-tools
----
* You have installed the Podman CLI tool (`podman`).
.Procedure
. Verify that you can build a {op-system-base} 8.7 image:
+
[source,terminal]
----
# composer-cli distros list
----
+
[NOTE]
====
To run the `composer-cli` commands as non-root, add your user to the `weldr` or `root` groups:
[source,terminal]
----
# usermod -a -G weldr user
----
[source,terminal]
----
$ newgrp weldr
----
====
. Enter the following command to create an image blueprint file in TOML format that contains the packages to be installed, kernel customizations, and the services to be disabled during boot time:
+
[source,terminal]
----
$ cat << EOF > dpdk-vm.toml
name = "dpdk_image"
description = "Image to use with the DPDK checkup"
version = "0.0.1"
distro = "rhel-87"
[[packages]]
name = "dpdk"
[[packages]]
name = "dpdk-tools"
[[packages]]
name = "driverctl"
[[packages]]
name = "tuned-profiles-cpu-partitioning"
[customizations.kernel]
append = "default_hugepagesz=1GB hugepagesz=1G hugepages=8 isolcpus=2-7"
[customizations.services]
disabled = ["NetworkManager-wait-online", "sshd"]
EOF
----
. Push the blueprint file to the image builder tool by running the following command:
+
[source,terminal]
----
# composer-cli blueprints push dpdk-vm.toml
----
. Generate the system image by specifying the blueprint name and output file format. The Universally Unique Identifier (UUID) of the image is displayed when you start the compose process.
+
[source,terminal]
----
# composer-cli compose start dpdk_image qcow2
----
. Wait for the compose process to complete. The compose status must show `FINISHED` before you can continue to the next step.
+
[source,terminal]
----
# composer-cli compose status
----
. Enter the following command to download the `qcow2` image file by specifying its UUID:
+
[source,terminal]
----
# composer-cli compose image <UUID>
----
. Create the customization scripts by running the following commands:
+
[source,terminal]
----
$ cat <<EOF >customize-vm
echo isolated_cores=2-7 > /etc/tuned/cpu-partitioning-variables.conf
tuned-adm profile cpu-partitioning
echo "options vfio enable_unsafe_noiommu_mode=1" > /etc/modprobe.d/vfio-noiommu.conf
EOF
----
+
[source,terminal]
----
$ cat <<EOF >first-boot
driverctl set-override 0000:06:00.0 vfio-pci
driverctl set-override 0000:07:00.0 vfio-pci
mkdir /mnt/huge
mount /mnt/huge --source nodev -t hugetlbfs -o pagesize=1GB
EOF
----
. Use the `virt-customize` tool to customize the image generated by the image builder tool:
+
[source,terminal]
----
$ virt-customize -a <UUID>.qcow2 --run=customize-vm --firstboot=first-boot --selinux-relabel
----
. To create a Dockerfile that contains all the commands to build the container disk image, enter the following command:
+
[source,terminal]
----
$ cat << EOF > Dockerfile
FROM scratch
COPY <uuid>-disk.qcow2 /disk/
EOF
----
+
where:
<uuid>-disk.qcow2:: Specifies the name of the custom image in `qcow2` format.
. Build and tag the container by running the following command:
+
[source,terminal]
----
$ podman build . -t dpdk-rhel:latest
----
. Push the container disk image to a registry that is accessible from your cluster by running the following command:
+
[source,terminal]
----
$ podman push dpdk-rhel:latest
----
. Provide a link to the container disk image in the `spec.param.vmContainerDiskImage` attribute in the DPDK checkup config map.

View File

@@ -19,9 +19,13 @@ include::modules/virt-checking-cluster-dpdk-readiness.adoc[leveloffset=+1]
include::modules/virt-dpdk-config-map-parameters.adoc[leveloffset=+2]
include::modules/virt-building-vm-containerdisk-image.adoc[leveloffset=+2]
[role="_additional-resources"]
[id="additional-resources_running-cluster-checkups"]
== Additional resources
* xref:../../../virt/virtual_machines/vm_networking/virt-attaching-vm-multiple-networks.adoc#virt-attaching-vm-multiple-networks[Attaching a virtual machine to multiple networks]
* xref:../../../networking/hardware_networks/using-dpdk-and-rdma.adoc#example-vf-use-in-dpdk-mode-intel_using-dpdk-and-rdma[Using a virtual function in DPDK mode with an Intel NIC]
* xref:../../../networking/hardware_networks/using-dpdk-and-rdma.adoc#nw-example-dpdk-line-rate_using-dpdk-and-rdma[Using SR-IOV and the Node Tuning Operator to achieve a DPDK line rate]
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/composing_a_customized_rhel_system_image/installing-composer_composing-a-customized-rhel-system-image[Installing image builder]
* link:https://access.redhat.com/solutions/253273[How to register and subscribe a RHEL system to the Red Hat Customer Portal using Red Hat Subscription Manager]