$ virtctl stop <my_vm_name>
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. |
You can create a virtual machine (VM) from an uploaded operating system image by using the Red Hat OpenShift Service on AWS web console.
You must have an IMG
, ISO
, or QCOW2
image file.
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.
You can generalize a Red Hat Enterprise Linux (RHEL) image to remove all system-specific configuration data before you use the image to create a golden image, a preconfigured snapshot of a virtual machine (VM). You can use a golden image to deploy new VMs.
You can generalize a RHEL VM by using the virtctl
, guestfs
, and virt-sysprep
tools.
You have a RHEL virtual machine (VM) to use as a base VM.
You have installed the OpenShift CLI (oc
).
You have installed the virtctl
tool.
Stop the RHEL VM if it is running, by entering the following command:
$ virtctl stop <my_vm_name>
Optional: Clone the virtual machine to avoid losing the data from your original VM. You can then generalize the cloned VM.
Retrieve the dataVolume
that stores the root filesystem for the VM by running the following command:
$ oc get vm <my_vm_name> -o jsonpath="{.spec.template.spec.volumes}{'\n'}"
[{"dataVolume":{"name":"<my_vm_volume>"},"name":"rootdisk"},{"cloudInitNoCloud":{...}]
Retrieve the persistent volume claim (PVC) that matches the listed dataVolume
by running the followimg command:
$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
<my_vm_volume> Bound …
If your cluster configuration does not enable you to clone a VM, to avoid losing the data from your original VM, you can clone the VM PVC to a data volume instead. You can then use the cloned PVC to create a golden image. If you are creating a golden image by cloning a PVC, continue with the next steps, using the cloned PVC. |
Deploy a new interactive container with libguestfs-tools
and attach the PVC to it by running the following command:
$ virtctl guestfs <my-vm-volume> --uid 107
This command opens a shell for you to run the next command.
Remove all configurations specific to your system by running the following command:
$ virt-sysprep -a disk.img
In the Red Hat OpenShift Service on AWS console, click Virtualization → Catalog.
Click Add volume.
In the Add volume window:
From the Source type list, select Use existing Volume.
From the Volume project list, select your project.
From the Volume name list, select the correct PVC.
In the Volume name field, enter a name for the new golden image.
From the Preference list, select the RHEL version you are using.
From the Default Instance Type list, select the instance type with the correct CPU and memory requirements for the version of RHEL you selected previously.
Click Save.
The new volume appears in the Select volume to boot from list. This is your new golden image. You can use this volume to create new VMs.
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 Red Hat OpenShift Service on AWS web console.
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.
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
with runStrategy: RerunOnFailure
and click Save.
Click the options menu and select Start.
The VM boots from the sysprep
disk containing the autounattend.xml
answer file.
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.
A running Windows VM with the QEMU guest agent installed.
In the Red Hat OpenShift Service on AWS 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 the sysprep
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 virtual machine (VM) configures the computer-specific information from a generalized Windows image onto the VM.
You must have a generalized Windows disk image.
You must create an unattend.xml
answer file. See the Microsoft documentation for details.
In the Red Hat OpenShift Service on AWS 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.
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.
You must have an ISO
, IMG
, or QCOW2
operating system image file.
For best performance, compress the image file by using the virt-sparsify tool or the xz
or gzip
utilities.
You must have virtctl
installed.
The client machine must be configured to trust the Red Hat OpenShift Service on AWS router’s certificate.
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. |
|
Optional. To verify that a data volume was created, view all data volumes by running the following command:
$ oc get dvs