Chapter 5. Deploying your customized images
After creating customized images for the VMWare vSphere private cloud, you can deploy the images to VMware vSphere. For the Guest image (.qcow2), and Installer (.iso), you can then download these images and deploy them to virtual machines.
You can only launch customized images directly from Hybrid Cloud Console to the following public clouds: AWS, GCP, and Azure. The VMDK customized images must first be uploaded to VMWare vSphere, deployed there, and then you can create a VM. For the Guest image (.qcow2), and Installer (.iso), you can then download these images and deploy them directly to virtual machines.
5.1. Configuring credentials to access your deployed systems with cloud-init Copy linkLink copied to clipboard!
You cannot add a username and password to a blueprint by using the Red Hat Lightspeed images UI interface. To add a username and password to your image, use the cloud-init tool.
The following example shows how to add credentials to a VMware OVA image type created with Lightspeed image builder. You can add credentials to other image types by using this method.
The Open virtualization format (.ova) is a .vmdk image with additional metadata about the virtual hardware. The .ova image contains the cloud-init package installed that you can use to provision users by using a user-data file, for example.
Instead of sharing your login credentials to a hosted service, use cloud-init and open-vm-tools, that are installed within the image and enabled by default. For example, you can use it to pass the credentials to the VMware vSphere Cloud Director by using cloud-init.
Prerequisites
-
You created an image in the
.ovaformat by using the Hybrid Cloud Console.
Procedure
-
Access the directory where you downloaded your
.ovaimage. Create a file named
metadata.yamland add the following information to this file:instance-id: cloud-vm local-hostname: vmname
instance-id: cloud-vm local-hostname: vmnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a file
userdata.yaml. Add the following information to the file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This file contains the administrator or root user credentials with no password that you can use to access your system after the first boot and create additional users later. The
ssh_authorized_keysfield is your SSH public key. You can find your SSH public key in~/.ssh/id_rsa.pub.
5.2. Configuring credentials to access your deployed systems with API Copy linkLink copied to clipboard!
You cannot add a username and password to a blueprint by using the Red Hat Lightspeed images UI interface. To add a username and password to your image, use the Image-builder service API.
The following example shows how to add credentials to a VMware OVA image type created with Lightspeed image builder. You can also use this method to add credentials to other image types.
Prerequisites
- Access to Hybrid Cloud Console.
- OAuth 2.0 authorization.
- You created an access token by using the Image Builder API. See Generating an access token for the Image Builder API queries.
-
The
jqtool is installed.
Procedure
Generate an access token for API queries by following the step in Generating an access token for the Image Builder API queries.
ImportantAccess tokens expire after fifteen (15) minutes. The expiration is included within the JSON response. You must repeat the process of obtaining an access token approximately every ten (10) minutes so that the token is rotated before it expires.
In your system, create a file in the
.jsonformat to create an image. The following example shows how to create an up-to-date RHEL 9.4ovaimage for x86_64 CPU architecture.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Send the compose request to the image builder API:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the request is successful, you can see an output similar to the following, that is the image ID:
{"id":"fd4ecf3c-f0ce-43dd-9fcc-6ad11208b939"}{"id":"fd4ecf3c-f0ce-43dd-9fcc-6ad11208b939"}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the status of the image building:
curl \ --silent \ --header "Authorization: Bearer $access_token" \ "https://console.redhat.com/api/image-builder/v1/composes/$compose_id" \ | image_ID.$ curl \ --silent \ --header "Authorization: Bearer $access_token" \ "https://console.redhat.com/api/image-builder/v1/composes/$compose_id" \ | image_ID.Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the request is successful, you can see an output similar to the following, that is the image ID:
{"id":"fd4ecf3c-f0ce-43dd-9fcc-6ad11208b939"}{"id":"fd4ecf3c-f0ce-43dd-9fcc-6ad11208b939"}Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can also check the image building progress by accessing Red Hat Hybrid Cloud Console.
After the image builds, you can see the following output:
If the request is successful, you can see an output similar to the following, that is the image ID:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After finishing the image creation, download the image.
curl --location --output vsphere-ova.vmdk \ “https://image-builder-service-production.s3.amazonaws.com/composer-api-76...-disk.ova?e42...”$ curl --location --output vsphere-ova.vmdk \ “https://image-builder-service-production.s3.amazonaws.com/composer-api-76...-disk.ova?e42...”Copy to Clipboard Copied! Toggle word wrap Toggle overflow The image is saved to your system and ready to be used.
5.3. Uploading VMDK images and creating a RHEL virtual machine in vSphere Copy linkLink copied to clipboard!
After creating and configuring your image, you can deploy it to VMware vSphere by using the CLI, and you can create a VM and log in to it.
Prerequisites
-
You configured credentials to access your deployed systems by using the
cloud-inittool. See Configuring credentials to access your deployed systems. You configured the
govcVMware CLI tool client with the following values in the environment by setting the following values in the environment:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Export the
metadata.yamlanduserdata.yamlfiles to the environment, compressed withgzip, encoded inbase64as follows. They will be used in further steps.export METADATA=$(gzip -c9 <metadata.yaml | { base64 -w0 2>/dev/null || base64; }) \ USERDATA=$(gzip -c9 <userdata.yaml | { base64 -w0 2>/dev/null || base64; })export METADATA=$(gzip -c9 <metadata.yaml | { base64 -w0 2>/dev/null || base64; }) \ USERDATA=$(gzip -c9 <userdata.yaml | { base64 -w0 2>/dev/null || base64; })Copy to Clipboard Copied! Toggle word wrap Toggle overflow Launch the image on vSphere with the
metadata.yamlanduserdata.yamlfiles:Import the
.vmdkimage in to vSphere:govc import.vmdk ./composer-api.vmdk foldername
$ govc import.vmdk ./composer-api.vmdk foldernameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the VM in vSphere without powering it on:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change the VM to add
ExtraConfigvariables, thecloud-initconfig:govc vm.change -vm vmname \ -e guestinfo.metadata="${METADATA}" \ -e guestinfo.metadata.encoding="gzip+base64" \ -e guestinfo.userdata="${USERDATA}" \ -e guestinfo.userdata.encoding="gzip+base64"govc vm.change -vm vmname \ -e guestinfo.metadata="${METADATA}" \ -e guestinfo.metadata.encoding="gzip+base64" \ -e guestinfo.userdata="${USERDATA}" \ -e guestinfo.userdata.encoding="gzip+base64"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Power-on the VM:
govc vm.power -on vmname
govc vm.power -on vmnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the VM IP address:
HOST=$(govc vm.ip vmname)
HOST=$(govc vm.ip vmname)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use SSH to log in to the VM, using the user-data specified in
cloud-initfile configuration:ssh admin@HOST
$ ssh admin@HOSTCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Deploying OVA VMDK images to the vSphere GUI Copy linkLink copied to clipboard!
After creating your .vmdk image in the open virtualization format (.ova), you can deploy it to VMware vSphere by using the vSphere GUI client. It will create a VM which can be customized further before booting.
Prerequisite
- You logged in to the vSphere UI in a browser.
-
You downloaded your (
.ova) image.
Procedure
- In the vSphere Client, from the Actions menu, select Deploy OVF Template.
- On the Deploy OVF Template page, complete the settings for each configuration option and click .
Click . The
.ovaimage starts to be deployed.After the image deployment is complete, you have a new virtual machine (VM) from the
.ovaimage.In the deployed image page, perform the following steps:
- From the Actions menu, select Edit Setting.
On the Virtual Hardware tab, configure resources such as CPU, memory, add a new network adapter, between others of your choice.
On the CD/DVD drive 1 option, attach a CD or DVD Drive that contains a
cloud-init.iso, to provision a user on startup.The VM is now ready to boot with the username and password from the
cloud-init.isofile.
Additional resources
5.5. Creating a virtual machine from the customized RHEL Guest system image Copy linkLink copied to clipboard!
You can create a virtual machine (VM) from the QCOW2 image that you created by using Lightspeed Images.
Prerequisites
- You created and downloaded a QCOW2 image by using Lightspeed Images.
Procedure
- Access the directory where you downloaded your QCOW2 image.
Create a file named
meta-data. Add the following information to this file:instance-id: nocloud local-hostname: vmname
instance-id: nocloud local-hostname: vmnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a file named
user-data. Add the following information to the file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
ssh_authorized_keysis your SSH public key. You can find your SSH public key in~/.ssh/id_rsa.pub.
-
Use the
genisoimagecommand to create an ISO image that includes theuser-dataandmeta-datafiles.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new VM from the KVM Guest Image using the
virt-installcommand. Include the ISO image you created on step 4 as an attachment to the VM image.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where,
- --graphics none - indicates that it is a headless RHEL Virtual Machine.
- --vcpus 4 - indicates that it uses 4 virtual CPUs.
- --memory 4096 - indicates that it uses 4096 MB RAM.
The VM installation starts:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.6. Installing a customized RHEL ISO system image to a bare metal system Copy linkLink copied to clipboard!
You can create a virtual machine (VM) from the ISO image that you created using the Lightspeed image builder.
Prerequisites
- You created and downloaded an ISO image by using Lightspeed image builder.
- A 8 GB USB flash drive.
Procedure
- Access the directory where you downloaded your ISO image.
- Place the bootable ISO image file on a USB flash drive.
- Connect the USB flash drive to the port of the computer you want to boot.
- Boot the ISO image from the USB flash drive.
Perform the steps to install the customized bootable ISO image.
The boot screen shows you the following options:
- Install Red Hat Enterprise Linux 1-latest
- Test this media & install Red Hat Enterprise Linux 1-latest
5.7. Importing and running QCOW2 images on OCI Copy linkLink copied to clipboard!
You can import your customized .qcow2 image to the Oracle Cloud Infrastructure (OCI). Then, you can launch the customized .qcow2 image on a virtual machine.
Prerequisites
- You logged in to the Oracle Cloud UI in a browser.
-
You downloaded your
.qcow2image. -
You have copied the
.qcow2image Image Link URL from Lightspeed Instance column, in the Images dashboard.
Procedure
- In the Oracle Cloud UI dashboard, click Compute > Custom Images.
- On the Custom Images dashboard, click Import image.
On the Import image window, set the following configuration:
- Select the Import from an object storage URL option.
- In the Object Storage URL field, paste the URL given by Lightspeed Images into it.
- Choose the QCOW2 image type.
- Under Launch mode, select the Paravirtualized mode option.
- Click .