Creating Virtual Machines
Create a virtual machine (a VirtualMachine resource) using an image, and schedule it to physical nodes with KubeVirt components installed and virtualization enabled. A VirtualMachine is the desired-state object (analogous to a Deployment); when it is started, KubeVirt produces a running VirtualMachineInstance (analogous to a Pod). For the terms used on this page, see Concepts and Glossary.
You can create a virtual machine through Create Virtual Machine using a form, and you may also switch to YAML format for the operation.
Prerequisites
-
Before creating a virtual machine using an image, please confirm the following with the platform administrator:
-
The target cluster is a self-built cluster, and the Kubevirt components have been deployed.
-
The target node must be a physical node with virtualization enabled.
-
A virtual machine image has been added to the platform.
-
-
If you need to use the physical GPU passthrough feature of the virtual machine, please contact the platform administrator for the following configuration:
-
Obtain GPU passthrough environment preparation plan and prepare the necessary environment.
-
Prepare the required physical GPU and enable the related features for physical GPU passthrough for the virtual machine.
-
Notes
When using Windows virtual machines, only logins via the username/password set in the virtual machine image are supported. Please contact the platform administrator to obtain this information in advance.
Create Virtual Machine
Procedure
Note: The following content presents an example of creating a virtual machine using a form, and you may also switch to YAML format for the operation.
-
Enter Container Platform.
-
In the left navigation bar, click Virtualization > Virtual Machines.
-
Click Create Virtual Machine.
-
In the Basic Information area, fill in the name and display name of the virtual machine and set tags or annotations.
-
Set the machine type and choose a virtual machine image.
-
In the Storage area, refer to the following instructions to configure the relevant information.
-
In the Network area, refer to the following instructions to configure the relevant information.
-
In the Initialization Settings area, refer to the following instructions to configure the relevant information.
-
(Optional) In the Advanced Configuration area, refer to the following instructions to configure the relevant information.
-
After confirming that the information is correct, click Create.
Wait for the virtual machine to change from Creating to Running status.
Related Operations
You can click the ⋮ icon on the right side of the list page or the Actions in the upper right corner of the details page to update or delete the virtual machine as needed. For other related operations like resetting passwords or updating keys, please refer to Manage Virtual Machines.
Note:
-
Updates can only be performed when the virtual machine is in Abnormal, Unknown, or Stopped status.
-
Updates do not support displaying disks that were separately attached or created after the virtual machine was created.
-
By default, Start Immediately is disabled during updates; you can enable it as needed.
Using the API
A virtual machine is a VirtualMachine (kubevirt.io/v1). The example below boots from a bootable volume (a DataSource), attaches a pod network, and injects an SSH key through cloud-init:
The boot disk is provisioned by the dataVolumeTemplates entry, which clones the referenced bootable volume. A virtual machine imported with a spec.instancetype reference (instead of inline resources) is also supported and is converted to an inline spec when you edit it — see Managing Virtual Machines.