Chapter 17. Preparing and uploading VMDK custom images to vSphere
You can create custom images and update them, either manually or automatically, to the VMware vSphere cloud by using RHEL image builder.
17.1. Creating and automatically uploading customized RHEL VMDK images by using image builder Copy linkLink copied to clipboard!
With RHEL image builder, you can create customized system images in the Open Virtualization Format (OVA), and automatically upload these images to the VMware vSphere client.
The OVA (.ova) is a .vmdk image with additional metadata about the virtual hardware, which contains a minimal template to make it easier to import images into vSphere. The .ovf (Open Virtualization Format) package is part of the vSphere .ova image. After RHEL image builder finishes importing the .ova image in the vSphere client, you can configure it with any additional hardware, such as network, disks, and CD-ROMs.
You can import the Open virtualization format (.ova) image by using either the vSphere GUI or the govc client. To upload the image by using the govc client, see Uploading VMDK images and creating a RHEL virtual machine in vSphere.
Prerequisites
- You opened the RHEL image builder app from the web console in a browser.
- You created a blueprint.
Procedure
-
In the RHEL image builder dashboard, click the
Blueprinttab. - On the blueprint table, find the blueprint you want to build an image.
- On the right side of the chosen blueprint, click Create Image. The Create image dialog wizard opens.
On the Image output page, complete the following steps:
- From the Select a blueprint list, select the image type you want.
- From the Image output type list, select the image output type you want.
- Optional: Check Upload to VMware checkbox to upload the image directly to VMware.
- Enter a size for the image.
- Click Next.
On the Upload to VMware page, enter the following information:
- Image name: Enter the image name.
- Host: Enter the VMware vSphere instance URL where the image file will be uploaded.
- Cluster: Enter the cluster name page to which the image will be uploaded.
- Datacenter: The data center name to which the image will be uploaded.
- Datastore: The data store name to which the image will be uploaded.
- Folder: Folder name to which the image will be uploaded.
- Click Next.
On the Review page, review the details about the image creation and click Create.
The image creation starts, showing the progress of this image creation and the subsequent upload to the VMware vSphere client.
17.2. Uploading VMDK images and creating a RHEL virtual machine in vSphere Copy linkLink copied to clipboard!
With RHEL image builder, you can create customized VMware vSphere system images, either in the Open virtualization Format (.ova) or in the Virtual Disk (.vmdk) format.
You can upload customized images to the VMware vSphere client. You can upload the .vmdk or .ova image to VMware vSphere using the govc import.vmdk CLI tool. The vmdk you create contains the cloud-init package installed, and you can use it to provision users by using user data, for example.
Uploading vmdk images by using the VMware vSphere GUI is not supported.
Prerequisites
- You created a blueprint with username and password customizations.
-
You created a VMware vSphere image either in the
.ovaor the.vmdkformat by using RHEL image builder and downloaded it to your host system. -
You installed and configured the
govcCLI tool to be able to use theimport.vmdkcommand.
Procedure
Configure the following values in the user environment with the GOVC environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Navigate to the directory where you downloaded your VMware vSphere image.
Launch the VMware vSphere image on vSphere by following the steps:
Import the VMware vSphere image into vSphere:
govc import.vmdk ./api.vmdk <folder-name>
$ govc import.vmdk ./api.vmdk <folder-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For the
.ovaformat:govc import.ova ./api.ova <folder-name>
$ govc import.ova ./api.ova <folder-name>Copy 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 For the
.ovaformat, replace the line-firmware=efi -disk="folder_name/api.vmdk”with-firmware=efi -disk=”<folder-name>/api.ova”Power-on the VM:
govc vm.power -on <vm-name>
$ govc vm.power -on <vm-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the VM IP address:
govc vm.ip <vm-name>
$ govc vm.ip <vm-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use SSH to log in to the VM, using the username and password you specified in your blueprint:
ssh admin@ <vm-ip-address>
$ ssh admin@ <vm-ip-address>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you copied the
.vmdkimage from your local host to the destination using thegovc datastore.uploadcommand, using the resulting image is not supported. There is no option to use theimport.vmdkcommand in the vSphere GUI and as a result, the vSphere GUI does not support the direct upload. The.vmdkimage is not usable from the vSphere GUI.
17.3. Creating and automatically uploading VMDK images to vSphere using image builder GUI Copy linkLink copied to clipboard!
You can build VMware images by using the RHEL image builder GUI tool and automatically push the images directly to your vSphere instance. This avoids the need to download the image file and push it manually.
The vmdk that you create contains the cloud-init package installed, and you can use it to provision users by using user data, for example. To build .vmdk images by using RHEL image builder and push them directly to the vSphere instances service provider, follow the steps:
Prerequisites
-
You are a member of the
rootor theweldrgroup. - You have opened RHEL image builder in a browser.
- You have created a blueprint.
- You have a vSphere Account.
Procedure
- For the blueprint you created, click the Images tab .
Click Create Image to create your customized image.
The Image type window opens.
In the Image type window:
-
From the dropdown menu, select the Type: VMware vSphere (
.vmdk). - Check the Upload to VMware checkbox to upload your image to vSphere.
- Optional: Set the size of the image you want to instantiate. The minimal default size is 2 GB.
- Click Next.
-
From the dropdown menu, select the Type: VMware vSphere (
In the Upload to VMware window, under Authentication, enter the following details:
- Username: username of the vSphere account.
- Password: password of the vSphere account.
In the Upload to VMware window, under Destination, enter the following details about the image upload destination:
- Image name: a name for the image.
- Host: The URL of your VMware vSphere.
- Cluster: The name of the cluster.
- Data center: The name of the data center.
- Data store: The name of the Data store.
- Click Next.
In the Review window, review the details of the image creation and click Finish.
You can click Back to modify any incorrect details.
RHEL image builder adds the compose of a RHEL vSphere image to the queue, and creates and uploads the image to the Cluster on the vSphere instance you specified.
After the process is complete, you can see the Image build complete status.
Verification
- Create a Virtual Machine (VM) from the image you uploaded and log in to it.
- Access VMware vSphere Client.
- Search for the image in the Cluster on the vSphere instance you specified.
- Select the image you uploaded.
- Right-click the selected image.
Click
New Virtual Machine.A New Virtual Machine window opens.
In the New Virtual Machine window, provide the following details:
-
Select
New Virtual Machine. - Select a name and a folder for your VM.
- Select a computer resource: choose a destination computer resource for this operation.
- Select storage: For example, select NFS-Node1
-
Select compatibility: The image should be
BIOSonly. -
Select a guest operating system: For example, select
LinuxandRed Hat Fedora (64-bit). - Customize hardware: When creating a VM, on the Device Configuration button on the upper right, delete the default New Hard Disk and use the drop-down to select an Existing Hard Disk disk image:
- Ready to complete: Review the details and click Finish to create the image.
-
Select
Navigate to the VMs tab.
- From the list, select the VM you created.
- Click the Start button on the panel. A new window appears, showing the VM image loading.
- Log in with the credentials you created for the blueprint.
You can verify if the packages you added to the blueprint are installed. For example:
rpm -qa | grep firefox
$ rpm -qa | grep firefoxCopy to Clipboard Copied! Toggle word wrap Toggle overflow