Skip to content

Commit a9e3b91

Browse files
authored
Merge pull request #59491 from sjhala-ccs/cnv-27612
CNV-27612: Procedure to build VM container disk image
2 parents 144971a + 9904cd2 commit a9e3b91

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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.

virt/support/monitoring/virt-running-cluster-checkups.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ include::modules/virt-checking-cluster-dpdk-readiness.adoc[leveloffset=+1]
1919

2020
include::modules/virt-dpdk-config-map-parameters.adoc[leveloffset=+2]
2121

22+
include::modules/virt-building-vm-containerdisk-image.adoc[leveloffset=+2]
23+
2224
[role="_additional-resources"]
2325
[id="additional-resources_running-cluster-checkups"]
2426
== Additional resources
2527
* xref:../../../virt/virtual_machines/vm_networking/virt-attaching-vm-multiple-networks.adoc#virt-attaching-vm-multiple-networks[Attaching a virtual machine to multiple networks]
2628
* 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]
2729
* 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]
30+
* 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]
31+
* 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]

0 commit comments

Comments
 (0)