Creating VMs by uploading images
You can create virtual machines (VMs) by uploading operating system images from your local machine.
You can create a Windows VM by uploading a Windows image to a PVC. Then you clone the PVC when you create the VM.
You must install the QEMU guest agent on VMs created from operating system images that are not provided by Red Hat. You must also install VirtIO drivers on Windows VMs. |
Creating a VM from an uploaded image by using the web console
You can create a virtual machine (VM) from an uploaded operating system image by using the OKD web console.
Prerequisites
- You must have an
IMG
,ISO
, orQCOW2
image file.
Procedure
Navigate to Virtualization → Catalog in the web console.
Click a template tile without an available boot source.
Click Customize VirtualMachine.
On the Customize template parameters page, expand Storage and select Upload (Upload a new file to a PVC) from the Disk source list.
Browse to the image on your local machine and set the disk size.
Click Customize VirtualMachine.
Click Create VirtualMachine.
Creating a Windows VM
You can create a Windows virtual machine (VM) by uploading a Windows image to a persistent volume claim (PVC) and then cloning the PVC when you create a VM by using the OKD web console.
Prerequisites
You created a Windows installation DVD or USB with the Windows Media Creation Tool. See Create Windows 10 installation media in the Microsoft documentation.
You created an
autounattend.xml
answer file. See Answer files (unattend.xml) in the Microsoft documentation.
Procedure
Upload the Windows image as a new PVC:
Navigate to Storage → PersistentVolumeClaims in the web console.
Click Create PersistentVolumeClaim → With Data upload form.
Browse to the Windows image and select it.
Enter the PVC name, select the storage class and size and then click Upload.
The Windows image is uploaded to a PVC.
Configure a new VM by cloning the uploaded PVC:
Navigate to Virtualization → Catalog.
Select a Windows template tile and click Customize VirtualMachine.
Select Clone (clone PVC) from the Disk source list.
Select the PVC project, the Windows image PVC, and the disk size.
Apply the answer file to the VM:
Click Customize VirtualMachine parameters.
On the Sysprep section of the Scripts tab, click Edit.
Browse to the
autounattend.xml
answer file and click Save.
Set the run strategy of the VM:
Clear Start this VirtualMachine after creation so that the VM does not start immediately.
Click Create VirtualMachine.
On the YAML tab, replace
running:false
withrunStrategy: RerunOnFailure
and click Save.
Click the options menu and select Start.
The VM boots from the
sysprep
disk containing theautounattend.xml
answer file.
Generalizing a Windows VM image
You can generalize a Windows operating system image to remove all system-specific configuration data before you use the image to create a new virtual machine (VM).
Before generalizing the VM, you must ensure the sysprep
tool cannot detect an answer file after the unattended Windows installation.
Prerequisites
- A running Windows VM with the QEMU guest agent installed.
Procedure
In the OKD console, click Virtualization → VirtualMachines.
Select a Windows VM to open the VirtualMachine details page.
Click Configuration → Disks.
Click the Options menu beside the
sysprep
disk and select Detach.Click Detach.
Rename
C:\Windows\Panther\unattend.xml
to avoid detection by thesysprep
tool.Start the
sysprep
program by running the following command:%WINDIR%\System32\Sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm
After the
sysprep
tool completes, the Windows VM shuts down. The disk image of the VM is now available to use as an installation image for Windows VMs.
You can now specialize the VM.
Specializing a Windows VM image
Specializing a Windows virtual machine (VM) configures the computer-specific information from a generalized Windows image onto the VM.
Prerequisites
You must have a generalized Windows disk image.
You must create an
unattend.xml
answer file. See the Microsoft documentation for details.
Procedure
In the OKD console, click Virtualization → Catalog.
Select a Windows template and click Customize VirtualMachine.
Select PVC (clone PVC) from the Disk source list.
Select the PVC project and PVC name of the generalized Windows image.
Click Customize VirtualMachine parameters.
Click the Scripts tab.
In the Sysprep section, click Edit, browse to the
unattend.xml
answer file, and click Save.Click Create VirtualMachine.
During the initial boot, Windows uses the unattend.xml
answer file to specialize the VM. The VM is now ready to use.
Additional resources for creating Windows VMs
Creating a VM from an uploaded image by using the command line
You can upload an operating system image by using the virtctl
command line tool. You can use an existing data volume or create a new data volume for the image.
Prerequisites
You must have an
ISO
,IMG
, orQCOW2
operating system image file.For best performance, compress the image file by using the virt-sparsify tool or the
xz
orgzip
utilities.You must have
virtctl
installed.The client machine must be configured to trust the OKD router’s certificate.
Procedure
Upload the image by running the
virtctl image-upload
command:$ virtctl image-upload dv <datavolume_name> \ (1)
--size=<datavolume_size> \ (2)
--image-path=</path/to/image> \ (3)
1 The name of the data volume. 2 The size of the data volume. For example: —size=500Mi
,—size=1G
3 The file path of the image. If you do not want to create a new data volume, omit the
—size
parameter and include the—no-create
flag.When uploading a disk image to a PVC, the PVC size must be larger than the size of the uncompressed virtual disk.
To allow insecure server connections when using HTTPS, use the
—insecure
parameter. When you use the—insecure
flag, the authenticity of the upload endpoint is not verified.
Optional. To verify that a data volume was created, view all data volumes by running the following command:
$ oc get dvs