이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 2. Creating RHEL KVM or RHOSP-compatible images
To create images that you can manage in the Red Hat OpenStack Platform (RHOSP) Image service (glance), you can use Red Hat Enterprise Linux (RHEL) Kernel-based Virtual Machine (KVM) instance images, or you can manually create RHOSP-compatible images in the QCOW2 format by using RHEL ISO files or Windows ISO files.
2.1. Creating RHEL KVM images 링크 복사링크가 클립보드에 복사되었습니다!
Use Red Hat Enterprise Linux (RHEL) Kernel-based Virtual Machine (KVM) instance images to create images that you can manage in the Red Hat OpenStack Platform (RHOSP) Image service (glance).
2.1.1. Using a RHEL KVM instance image with Red Hat OpenStack Platform 링크 복사링크가 클립보드에 복사되었습니다!
You can use one of the following Red Hat Enterprise Linux (RHEL) Kernel-based Virtual Machine (KVM) instance images with Red Hat OpenStack Platform (RHOSP):
These QCOW2 images are configured with cloud-init and must have EC2-compatible metadata services for provisioning Secure Shell (SSH) keys to function correctly.
Ready Windows KVM instance images in QCOW2 format are not available.
For KVM instance images:
-
The
rootaccount in the image is deactivated, butsudoaccess is granted to a special user namedcloud-user. -
There is no
rootpassword set for this image.
The root password is locked in /etc/shadow by placing !! in the second field.
For a RHOSP instance, generate an SSH keypair from the RHOSP dashboard or command line, and use that key combination to perform an SSH public authentication to the instance as root user.
When you launch the instance, this public key is injected to it. You can then authenticate by using the private key that you download when you create the keypair.
2.1.2. Creating a RHEL-based root partition image for bare-metal instances 링크 복사링크가 클립보드에 복사되었습니다!
To create a custom root partition image for bare-metal instances, download the base Red Hat Enterprise Linux KVM instance image, and then upload the image to the Image service (glance).
Procedure
- Download the base Red Hat Enterprise Linux KVM instance image from the Customer Portal.
Define
DIB_LOCAL_IMAGEas the downloaded image:$ export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2-
Replace
<ver>with the RHEL version number of the image.
-
Replace
Set your registration information depending on your method of registration:
Red Hat Customer Portal:
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_AUTO_ATTACH=true $ export REG_METHOD=portal $ export https_proxy='<IP_address:port>' (if applicable) $ export http_proxy='<IP_address:port>' (if applicable)Red Hat Satellite:
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_SAT_URL='<satellite-url>' $ export REG_ORG='<satellite-org>' $ export REG_ENV='<satellite-env>' $ export REG_METHOD=<method>-
Replace values in angle brackets
<>with the correct values for your Red Hat Customer Portal or Red Hat Satellite registration.
Optional: If you have any offline repositories, you can define
DIB_YUM_REPO_CONFas a local repository configuration:$ export DIB_YUM_REPO_CONF=<file-path>-
Replace
<file-path>with the path to your local repository configuration file.
-
Replace
Use the
diskimage-buildertool to extract the kernel asrhel-image.vmlinuzand the initial RAM disk asrhel-image.initrd:$ export DIB_RELEASE=<ver> $ disk-image-create rhel baremetal \ -o rhel-imageUpload the images to the Image service:
$ KERNEL_ID=$(openstack image create \ --file rhel-image.vmlinuz --public \ --container-format aki --disk-format aki \ -f value -c id rhel-image.vmlinuz) $ RAMDISK_ID=$(openstack image create \ --file rhel-image.initrd --public \ --container-format ari --disk-format ari \ -f value -c id rhel-image.initrd) $ openstack image create \ --file rhel-image.qcow2 --public \ --container-format bare \ --disk-format qcow2 \ --property kernel_id=$KERNEL_ID \ --property ramdisk_id=$RAMDISK_ID \ rhel-root-partition-bare-metal-image
2.1.3. Creating a RHEL-based whole-disk user image for bare-metal instances 링크 복사링크가 클립보드에 복사되었습니다!
To create a whole-disk user image for bare-metal instances, download the base Red Hat Enterprise Linux KVM instance image, and then upload the image to the Image service (glance).
Procedure
- Download the base Red Hat Enterprise Linux KVM instance image from the Customer Portal.
Define
DIB_LOCAL_IMAGEas the downloaded image:$ export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2-
Replace
<ver>with the RHEL version number of the image.
-
Replace
Set your registration information depending on your method of registration:
Red Hat Customer Portal:
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_AUTO_ATTACH=true $ export REG_METHOD=portal $ export https_proxy='<IP_address:port>' (if applicable) $ export http_proxy='<IP_address:port>' (if applicable)Red Hat Satellite:
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_SAT_URL='<satellite-url>' $ export REG_ORG='<satellite-org>' $ export REG_ENV='<satellite-env>' $ export REG_METHOD=<method>-
Replace values in angle brackets
<>with the correct values for your Red Hat Customer Portal or Red Hat Satellite registration.
Optional: If you have any offline repositories, you can define
DIB_YUM_REPO_CONFas a local repository configuration:$ export DIB_YUM_REPO_CONF=<file-path>-
Replace
<file-path>with the path to your local repository configuration file.
-
Replace
Upload the image to the Image service:
$ openstack image create \ --file rhel-image.qcow2 --public \ --container-format bare \ --disk-format qcow2 \ rhel-whole-disk-bare-metal-image
2.2. Creating instance images with RHEL or Windows ISO files 링크 복사링크가 클립보드에 복사되었습니다!
You can create custom Red Hat Enterprise Linux (RHEL) or Windows images in QCOW2 format from ISO files, and upload these images to the Red Hat OpenStack Platform (RHOSP) Image service (glance) for use when creating instances.
2.2.1. Prerequisites 링크 복사링크가 클립보드에 복사되었습니다!
- A Linux host machine to create an image. This can be any machine on which you can install and run the Linux packages, except for the undercloud or the overcloud.
The
advanced-virtrepository is enabled:$ sudo subscription-manager repos --enable=advanced-virt-for-rhel-<ver>-x86_64-rpmsThe
virt-managerapplication is installed to have all packages necessary to create a guest operating system:$ sudo dnf module install -y virtThe
libguestfs-toolspackage is installed to have a set of tools to access and modify virtual machine images:$ sudo dnf install -y libguestfs-tools-c- A RHEL 9 or 8 ISO file or a Windows ISO file. For more information about RHEL ISO files, see RHEL 9.0 Binary DVD or RHEL 8.6 Binary DVD. If you do not have a Windows ISO file, see the Microsoft Evaluation Center to download an evaluation image.
-
A text editor, if you want to change the
kickstartfiles (RHEL only).
If you install the libguestfs-tools package on the undercloud, deactivate iscsid.socket to avoid port conflicts with the tripleo_iscsid service on the undercloud:
$ sudo systemctl disable --now iscsid.socket
When you have the prerequisites in place, you can proceed to create a RHEL or Windows image:
2.2.2. Creating a Red Hat Enterprise Linux 9 image 링크 복사링크가 클립보드에 복사되었습니다!
You can create a Red Hat OpenStack Platform (RHOSP) image in QCOW2 format by using a Red Hat Enterprise Linux (RHEL) 9 ISO file.
Procedure
-
Log on to your host machine as the
rootuser. Start the installation by using
virt-install:[root@host]# virt-install \ --virt-type kvm \ --name <rhel9-cloud-image> \ --ram <2048> \ --cdrom </var/lib/libvirt/images/rhel-9.0-x86_64-dvd.iso> \ --disk <rhel9.qcow2>,format=qcow2,size=<10> \ --network=bridge:virbr0 \ --graphics vnc,listen=127.0.0.1 \ --noautoconsole \ --os-variant=<rhel9.0>Replace the values in angle brackets
<>with the correct values for your RHEL 9 image.This command launches an instance and starts the installation process.
NoteIf the instance does not launch automatically, run the
virt-viewercommand to view the console:[root@host]# virt-viewer <rhel9-cloud-image>
Configure the instance:
- At the initial Installer boot menu, select Install Red Hat Enterprise Linux 9.
- Choose the appropriate Language and Keyboard options.
- When prompted about which type of devices your installation uses, select Auto-detected installation media.
- When prompted about which type of installation destination, select Local Standard Disks. For other storage options, select Automatically configure partitioning.
- In the Which type of installation would you like? window, choose the Basic Server install, which installs an SSH server.
- For network and host name, select eth0 for network and choose a host name for your device. The default host name is localhost.localdomain.
- Enter a password in the Root Password field and enter the same password again in the Confirm field.
- When the on-screen message confirms that the installation is complete, reboot the instance and log in as the root user.
Update the
/etc/sysconfig/network-scripts/ifcfg-eth0file so that it contains only the following values:TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no- Reboot the machine.
Register the machine with the Content Delivery Network.
# sudo subscription-manager register # sudo subscription-manager attach \ --pool=<pool-id> # sudo subscription-manager repos \ --enable rhel-9-for-x86_64-baseos-rpms \ --enable rhel-9-for-x86_64-appstream-rpms-
Replace
pool-idwith a valid pool ID. You can see a list of available pool IDs by running thesubscription-manager list --availablecommand.
-
Replace
Update the system:
# dnf -y updateInstall the
cloud-initpackages:# dnf install -y cloud-utils-growpart cloud-initEdit the
/etc/cloud/cloud.cfgconfiguration file and add the following content undercloud_init_modules:- resolv-confThe
resolv-confoption automatically configures theresolv.conffile when an instance boots for the first time. This file contains information related to the instance such asnameservers,domain, and other options.Add the following line to
/etc/sysconfig/networkto avoid issues when accessing the EC2 metadata service:NOZEROCONF=yesTo ensure that the console messages appear in the Log tab on the dashboard and the
nova console-logoutput, add the following boot option to the/etc/default/grubfile:GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"Run the
grub2-mkconfigcommand:# grub2-mkconfig -o /boot/grub2/grub.cfgThe output is as follows:
Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-229.9.2.el9.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.9.2.el9.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-121.el9.x86_64 Found initrd image: /boot/initramfs-3.10.0-121.el9.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-b82a3044fb384a3f9aeacf883474428b Found initrd image: /boot/initramfs-0-rescue-b82a3044fb384a3f9aeacf883474428b.img doneDeregister the instance so that the resulting image does not contain the subscription details for this instance:
# subscription-manager repos --disable=* # subscription-manager unregister # dnf clean allPower off the instance:
# poweroffReset and clean the image by using the
virt-sysprepcommand so that it can be used to create instances without issues:[root@host]# virt-sysprep -d <rhel9-cloud-image>Reduce the image size by converting any free space in the disk image back to free space in the host:
[root@host]# virt-sparsify \ --compress <rhel9.qcow2> <rhel9-cloud.qcow2>This command creates a new
<rhel9-cloud.qcow2>file in the location from where the command is run.NoteYou must manually resize the partitions of instances based on the image in accordance with the disk space in the flavor that is applied to the instance.
The <rhel9-cloud.qcow2> image file is ready to be uploaded to the Image service. For more information about uploading this image to your RHOSP deployment, see Uploading images to the Image service.
2.2.3. Creating a Red Hat Enterprise Linux 8 image 링크 복사링크가 클립보드에 복사되었습니다!
You can create a Red Hat OpenStack Platform (RHOSP) image in QCOW2 format by using a Red Hat Enterprise Linux (RHEL) 8 ISO file.
Procedure
-
Log on to your host machine as the
rootuser. Start the installation by using
virt-install:[root@host]# virt-install \ --virt-type kvm \ --name <rhel86-cloud-image> \ --ram <2048> \ --vcpus <2> \ --disk <rhel86.qcow2>,format=qcow2,size=<10> \ --location <rhel-8.6-x86_64-boot.iso> \ --network=bridge:virbr0 \ --graphics vnc,listen=127.0.0.1 \ --noautoconsole \ --os-variant <rhel8.6>Replace the values in angle brackets
<>with the correct values for your RHEL image.This command launches an instance and starts the installation process.
NoteIf the instance does not launch automatically, run the
virt-viewercommand to view the console:[root@host]# virt-viewer <rhel86-cloud-image>
Configure the instance:
- At the initial Installer boot menu, select Install Red Hat Enterprise Linux 8.
- Choose the appropriate Language and Keyboard options.
- When prompted about which type of devices your installation uses, select Basic Storage Devices.
-
Choose a host name for your device. The default host name is
localhost.localdomain. -
Set the timezone and
rootpassword. - In the Which type of installation would you like? window, choose the Basic Server install, which installs an SSH server.
- When the on-screen message confirms that the installation is complete, reboot the instance and log in as the root user.
Update the
/etc/sysconfig/network-scripts/ifcfg-eth0file so that it contains only the following values:TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no- Reboot the machine.
Register the machine with the Content Delivery Network:
# sudo subscription-manager register # sudo subscription-manager attach \ --pool=<pool-id> # sudo subscription-manager repos \ --enable rhel-8-for-x86_64-baseos-rpms \ --enable rhel-8-for-x86_64-appstream-rpms-
Replace
pool-idwith a valid pool ID. You can see a list of available pool IDs by running thesubscription-manager list --availablecommand.
-
Replace
Update the system:
# dnf -y updateInstall the
cloud-initpackages:# dnf install -y cloud-utils-growpart cloud-initEdit the
/etc/cloud/cloud.cfgconfiguration file and add the following content undercloud_init_modules.- resolv-confThe
resolv-confoption automatically configures theresolv.conffile when an instance boots for the first time. This file contains information related to the instance such asnameservers,domain, and other options.To prevent network issues, create
/etc/udev/rules.d/75-persistent-net-generator.rules:# echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rulesThis prevents the
/etc/udev/rules.d/70-persistent-net.rulesfile from being created. If the/etc/udev/rules.d/70-persistent-net.rulesfile is created, networking might not function correctly when you boot from snapshots because the network interface is created aseth1instead ofeth0and the IP address is not assigned.Add the following line to
/etc/sysconfig/networkto avoid issues when accessing the EC2 metadata service:NOZEROCONF=yesTo ensure that the console messages appear in the Log tab on the dashboard and the
nova console-logoutput, add the following boot option to the/etc/grub.conffile:GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"Deregister the instance so that the resulting image does not contain the same subscription details for this instance:
# subscription-manager repos --disable=* # subscription-manager unregister # dnf clean allPower off the instance:
# poweroffReset and clean the image by using the
virt-sysprepcommand so that it can be used to create instances without issues:[root@host]# virt-sysprep -d <rhel86-cloud-image>Reduce the image size by converting any free space in the disk image back to free space in the host:
[root@host]# virt-sparsify \ --compress <rhel86.qcow2> <rhel86-cloud.qcow2>This command creates a new
<rhel86-cloud.qcow2>file in the location from where the command is run.NoteYou must manually resize the partitions of instances based on the image in accordance with the disk space in the flavor that is applied to the instance.
The <rhel86-cloud.qcow2> image file is ready to be uploaded to the Image service. For more information about uploading this image to your RHOSP deployment, see Uploading images to the Image service.
2.2.4. Creating a Windows image 링크 복사링크가 클립보드에 복사되었습니다!
You can create a Red Hat OpenStack Platform (RHOSP) image in QCOW2 format by using a Windows ISO file.
Procedure
-
Log on to your host machine as the
rootuser. Start the installation by using
virt-install:[root@host]# virt-install \ --name=<windows-image> \ --disk size=<size> \ --cdrom=<file-path-to-windows-iso-file> \ --os-type=windows \ --network=bridge:virbr0 \ --graphics spice \ --ram=<ram>Replace the values in angle brackets
<>withe the correct values for your Windows image.NoteThe
--os-type=windowsparameter ensures that the clock is configured correctly for the Windows instance and enables its Hyper-V enlightenment features. You must also setos_type=windowsin the image metadata before uploading the image to the Image service (glance).
The
virt-installcommand saves the instance image as/var/lib/libvirt/images/<windows-image>.qcow2by default. If you want to keep the instance image elsewhere, change the parameter of the--diskoption:--disk path=<file-name>,size=<size>Replace
<file-name>with the name of the file that stores the instance image, and optionally its path. For example,path=win8.qcow2,size=8creates an 8 GB file namedwin8.qcow2in the current working directory.NoteIf the instance does not launch automatically, run the
virt-viewercommand to view the console:[root@host]# virt-viewer <windows-image>For more information about how to install Windows, see the Microsoft documentation.
- To allow the newly-installed Windows system to use the virtualized hardware, you might need to install VirtIO drivers. For more information, see Installing KVM paravirtualized drivers for Windows virtual machines in Configuring and managing virtualization.
To complete the configuration, download and run Cloudbase-Init on the Windows system. At the end of the installation of Cloudbase-Init, select the Run Sysprep and Shutdown checkboxes. The
Syspreptool makes the instance unique by generating an OS ID, which is used by certain Microsoft services.ImportantRed Hat does not provide technical support for Cloudbase-Init. If you encounter an issue, see Contact Cloudbase Solutions.
When the Windows system shuts down, the
<windows-image.qcow2>image file is ready to be uploaded to the Image service. For more information about uploading this image to your RHOSP deployment, see Uploading images to the Image service.
2.3. Creating an image for UEFI Secure Boot 링크 복사링크가 클립보드에 복사되었습니다!
When the overcloud contains UEFI Secure Boot Compute nodes, you can create a Secure Boot instance image that cloud users can use to launch Secure Boot instances.
Procedure
Create a new image for UEFI Secure Boot:
$ openstack image create --file <base_image_file> uefi_secure_boot_image-
Replace
<base_image_file>with an image file that supports UEFI and the GUID Partition Table (GPT) standard, and includes an EFI system partition.
-
Replace
If the default machine type is not
q35, then set the machine type toq35:$ openstack image set --property hw_machine_type=q35 uefi_secure_boot_imageSpecify that the instance must be scheduled on a UEFI Secure Boot host:
$ openstack image set \ --property hw_firmware_type=uefi \ --property os_secure_boot=required \ uefi_secure_boot_image
2.4. Metadata properties for virtual hardware 링크 복사링크가 클립보드에 복사되었습니다!
The Compute service (nova) has deprecated support for using libosinfo data to set default device models. Instead, use the following image metadata properties to configure the optimal virtual hardware for an instance:
-
os_distro -
os_version -
hw_cdrom_bus -
hw_disk_bus -
hw_scsi_model -
hw_vif_model -
hw_video_model -
hypervisor_type
For more information about these metadata properties, see Image configuration parameters.