|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt//support/monitoring/virt-running-cluster-checkups.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="virt-building-vm-containerdisk-image_{context}"] |
| 7 | += Building a container disk image for {op-system-base} virtual machines |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +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. |
| 12 | + |
| 13 | + |
| 14 | +.Prerequisites |
| 15 | +* 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. |
| 16 | +* You have installed the image builder tool and its CLI (`composer-cli`) on the VM. |
| 17 | +
|
| 18 | +* You have installed the `virt-customize` tool: |
| 19 | ++ |
| 20 | +[source,terminal] |
| 21 | +---- |
| 22 | +# dnf install libguestfs-tools |
| 23 | +---- |
| 24 | +* You have installed the Podman CLI tool (`podman`). |
| 25 | +
|
| 26 | +.Procedure |
| 27 | + |
| 28 | +. Verify that you can build a {op-system-base} 8.7 image: |
| 29 | ++ |
| 30 | +[source,terminal] |
| 31 | +---- |
| 32 | +# composer-cli distros list |
| 33 | +---- |
| 34 | ++ |
| 35 | +[NOTE] |
| 36 | +==== |
| 37 | +To run the `composer-cli` commands as non-root, add your user to the `weldr` or `root` groups: |
| 38 | +
|
| 39 | +[source,terminal] |
| 40 | +---- |
| 41 | +# usermod -a -G weldr user |
| 42 | +---- |
| 43 | +[source,terminal] |
| 44 | +---- |
| 45 | +$ newgrp weldr |
| 46 | +---- |
| 47 | +==== |
| 48 | + |
| 49 | +. 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: |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +$ cat << EOF > dpdk-vm.toml |
| 54 | +name = "dpdk_image" |
| 55 | +description = "Image to use with the DPDK checkup" |
| 56 | +version = "0.0.1" |
| 57 | +distro = "rhel-87" |
| 58 | + |
| 59 | +[[packages]] |
| 60 | +name = "dpdk" |
| 61 | + |
| 62 | +[[packages]] |
| 63 | +name = "dpdk-tools" |
| 64 | + |
| 65 | +[[packages]] |
| 66 | +name = "driverctl" |
| 67 | + |
| 68 | +[[packages]] |
| 69 | +name = "tuned-profiles-cpu-partitioning" |
| 70 | + |
| 71 | +[customizations.kernel] |
| 72 | +append = "default_hugepagesz=1GB hugepagesz=1G hugepages=8 isolcpus=2-7" |
| 73 | + |
| 74 | +[customizations.services] |
| 75 | +disabled = ["NetworkManager-wait-online", "sshd"] |
| 76 | +EOF |
| 77 | +---- |
| 78 | + |
| 79 | +. Push the blueprint file to the image builder tool by running the following command: |
| 80 | ++ |
| 81 | +[source,terminal] |
| 82 | +---- |
| 83 | +# composer-cli blueprints push dpdk-vm.toml |
| 84 | +---- |
| 85 | + |
| 86 | +. 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. |
| 87 | ++ |
| 88 | +[source,terminal] |
| 89 | +---- |
| 90 | +# composer-cli compose start dpdk_image qcow2 |
| 91 | +---- |
| 92 | + |
| 93 | +. Wait for the compose process to complete. The compose status must show `FINISHED` before you can continue to the next step. |
| 94 | ++ |
| 95 | +[source,terminal] |
| 96 | +---- |
| 97 | +# composer-cli compose status |
| 98 | +---- |
| 99 | + |
| 100 | +. Enter the following command to download the `qcow2` image file by specifying its UUID: |
| 101 | ++ |
| 102 | +[source,terminal] |
| 103 | +---- |
| 104 | +# composer-cli compose image <UUID> |
| 105 | +---- |
| 106 | + |
| 107 | +. Create the customization scripts by running the following commands: |
| 108 | ++ |
| 109 | +[source,terminal] |
| 110 | +---- |
| 111 | +$ cat <<EOF >customize-vm |
| 112 | +echo isolated_cores=2-7 > /etc/tuned/cpu-partitioning-variables.conf |
| 113 | +tuned-adm profile cpu-partitioning |
| 114 | +echo "options vfio enable_unsafe_noiommu_mode=1" > /etc/modprobe.d/vfio-noiommu.conf |
| 115 | +EOF |
| 116 | +---- |
| 117 | ++ |
| 118 | +[source,terminal] |
| 119 | +---- |
| 120 | +$ cat <<EOF >first-boot |
| 121 | +driverctl set-override 0000:06:00.0 vfio-pci |
| 122 | +driverctl set-override 0000:07:00.0 vfio-pci |
| 123 | +
|
| 124 | +mkdir /mnt/huge |
| 125 | +mount /mnt/huge --source nodev -t hugetlbfs -o pagesize=1GB |
| 126 | +EOF |
| 127 | +---- |
| 128 | + |
| 129 | +. Use the `virt-customize` tool to customize the image generated by the image builder tool: |
| 130 | ++ |
| 131 | +[source,terminal] |
| 132 | +---- |
| 133 | +$ virt-customize -a <UUID>.qcow2 --run=customize-vm --firstboot=first-boot --selinux-relabel |
| 134 | +---- |
| 135 | + |
| 136 | +. To create a Dockerfile that contains all the commands to build the container disk image, enter the following command: |
| 137 | ++ |
| 138 | +[source,terminal] |
| 139 | +---- |
| 140 | +$ cat << EOF > Dockerfile |
| 141 | +FROM scratch |
| 142 | +COPY <uuid>-disk.qcow2 /disk/ |
| 143 | +EOF |
| 144 | +---- |
| 145 | ++ |
| 146 | +where: |
| 147 | + |
| 148 | +<uuid>-disk.qcow2:: Specifies the name of the custom image in `qcow2` format. |
| 149 | + |
| 150 | +. Build and tag the container by running the following command: |
| 151 | ++ |
| 152 | +[source,terminal] |
| 153 | +---- |
| 154 | +$ podman build . -t dpdk-rhel:latest |
| 155 | +---- |
| 156 | + |
| 157 | +. Push the container disk image to a registry that is accessible from your cluster by running the following command: |
| 158 | ++ |
| 159 | +[source,terminal] |
| 160 | +---- |
| 161 | +$ podman push dpdk-rhel:latest |
| 162 | +---- |
| 163 | + |
| 164 | +. Provide a link to the container disk image in the `spec.param.vmContainerDiskImage` attribute in the DPDK checkup config map. |
0 commit comments