apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachineInstancetype
metadata:
name: example-instancetype
spec:
cpu:
guest: 1 (1)
memory:
guest: 128Mi (2)
You can simplify virtual machine (VM) creation by using instance types, whether you use the OpenShift Container Platform web console or the CLI to create VMs.
An instance type is a reusable object where you can define resources and characteristics to apply to new VMs. You can define custom instance types or use the variety that are included when you install OpenShift Virtualization.
To create a new instance type, you must first create a manifest, either manually or by using the virtctl
CLI tool. You then create the instance type object by applying the manifest to your cluster.
OpenShift Virtualization provides two CRDs for configuring instance types:
A namespaced object: VirtualMachineInstancetype
A cluster-wide object: VirtualMachineClusterInstancetype
These objects use the same VirtualMachineInstancetypeSpec
.
When you configure an instance type, you must define the cpu
and memory
attributes. Other attributes are optional.
When you create a VM from an instance type, you cannot override any parameters defined in the instance type. Because instance types require defined CPU and memory attributes, OpenShift Virtualization always rejects additional requests for these resources when creating a VM from an instance type. |
You can manually create an instance type manifest. For example:
apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachineInstancetype
metadata:
name: example-instancetype
spec:
cpu:
guest: 1 (1)
memory:
guest: 128Mi (2)
1 | Required. Specifies the number of vCPUs to allocate to the guest. |
2 | Required. Specifies an amount of memory to allocate to the guest. |
You can create an instance type manifest by using the virtctl
CLI utility. For example:
virtctl
command with required fields$ virtctl create instancetype --cpu 2 --memory 256Mi
where:
--cpu <value>
Specifies the number of vCPUs to allocate to the guest. Required.
--memory <value>
Specifies an amount of memory to allocate to the guest. Required.
You can immediately create the object from the new manifest by running the following command:
|
In addition to the required cpu
and memory
attributes, you can include the following optional attributes in the VirtualMachineInstancetypeSpec
:
annotations
List annotations to apply to the VM.
gpus
List vGPUs for passthrough.
hostDevices
List host devices for passthrough.
ioThreadsPolicy
Define an IO threads policy for managing dedicated disk access.
launchSecurity
Configure Secure Encrypted Virtualization (SEV).
nodeSelector
Specify node selectors to control the nodes where this VM is scheduled.
schedulerName
Define a custom scheduler to use for this VM instead of the default scheduler.
OpenShift Virtualization includes a set of pre-defined instance types called common-instancetypes
. Some are specialized for specific workloads and others are workload-agnostic.
These instance type resources are named according to their series, version, and size. The size value follows the .
delimiter and ranges from nano
to 8xlarge
.
Use case | Series | Characteristics | vCPU to memory ratio | Example resource |
---|---|---|---|---|
Universal |
U |
|
1:4 |
|
Overcommitted |
O |
|
1:4 |
|
Compute-exclusive |
CX |
|
1:2 |
|
NVIDIA GPU |
GN |
|
1:4 |
|
Memory-intensive |
M |
|
1:8 |
|
Network-intensive |
N |
|
1:2 |
|
You can use the virtctl
CLI utility to simplify creating manifests for VMs, VM instance types, and VM preferences. For more information, see VM manifest creation commands.
If you have a VirtualMachine
manifest, you can create a VM from the command line.
You can create a virtual machine (VM) from an instance type by using the OpenShift Container Platform web console. You can also use the web console to create a VM by copying an existing snapshot or to clone a VM.
In the web console, navigate to Virtualization → Catalog and click the InstanceTypes tab.
Select either of the following options:
Select a bootable volume.
The bootable volume table lists only those volumes in the |
Optional: Click the star icon to designate a bootable volume as a favorite. Starred bootable volumes appear first in the volume list.
Click Add volume to upload a new volume or use an existing persistent volume claim (PVC), volume snapshot, or data source. Then click Save.
Click an instance type tile and select the resource size appropriate for your workload.
If you have not already added a public SSH key to your project, click the edit icon beside Authorized SSH key in the VirtualMachine details section.
Select one of the following options:
Use existing: Select a secret from the secrets list.
Add new:
Browse to the public SSH key file or paste the file in the key field.
Enter the secret name.
Optional: Select Automatically apply this key to any new VirtualMachine you create in this project.
Click Save.
Optional: Click View YAML & CLI to view the YAML file. Click CLI to view the CLI commands. You can also download or copy either the YAML file contents or the CLI commands.
Click Create VirtualMachine.
After the VM is created, you can monitor the status on the VirtualMachine details page.