17.2. Uploading VMDK images and creating a RHEL virtual machine in vSphere
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:
GOVC_URL GOVC_DATACENTER GOVC_FOLDER GOVC_DATASTORE GOVC_RESOURCE_POOL GOVC_NETWORK- 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>For the
.ovaformat:$ govc import.ova ./api.ova <folder-name>
Create the VM in vSphere without powering it on:
govc vm.create \ -net.adapter=vmxnet3 \ -m=4096 -c=2 -g=rhel8_64Guest \ -firmware=efi -disk="<folder-name>/api.vmdk” \ -disk.controller=scsi -on=false \ vmnameFor 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>Retrieve the VM IP address:
$ govc vm.ip <vm-name>Use SSH to log in to the VM, using the username and password you specified in your blueprint:
$ ssh admin@ <vm-ip-address>注意If 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.