This is a cache of https://docs.openshift.com/container-platform/4.16/virt/virtual_machines/creating_vms_rh/virt-creating-vms-from-instance-types.html. It is a snapshot of the page at 2024-11-25T11:20:08.897+0000.
Creating VMs from instance types - Virtual machines | Virtualization | OpenShift Container Platform 4.16
×

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.

About instance types

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.

Required attributes

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:

Example YAML file with required fields
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:

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:

$ virtctl create instancetype --cpu 2 --memory 256Mi | oc apply -f -

Optional attributes

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.

Pre-defined instance types

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.

Table 1. common-instancetypes series comparison
Use case Series Characteristics vCPU to memory ratio Example resource

Universal

U

  • Burstable CPU performance

1:4

u1.medium
  • 1 vCPUs

  • 4 Gi memory

Overcommitted

O

  • Overcommitted memory

  • Burstable CPU performance

1:4

o1.small
  • 1 vCPU

  • 2Gi memory

Compute-exclusive

CX

  • Hugepages

  • Dedicated CPU

  • Isolated emulator threads

  • vNUMA

1:2

cx1.2xlarge
  • 8 vCPUs

  • 16Gi memory

NVIDIA GPU

GN

  • For VMs that use GPUs provided by the NVIDIA GPU Operator

  • Has predefined GPUs

  • Burstable CPU performance

1:4

gn1.8xlarge
  • 32 vCPUs

  • 128Gi memory

Memory-intensive

M

  • Hugepages

  • Burstable CPU performance

1:8

m1.large
  • 2 vCPUs

  • 16Gi memory

Network-intensive

N

  • Hugepages

  • Dedicated CPU

  • Isolated emulator threads

  • Requires nodes capable of running DPDK workloads

1:2

n1.medium
  • 4 vCPUs

  • 4Gi memory

Creating manifests by using the virtctl tool

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.

Creating a VM from an instance type by using the web console

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.

You can create a VM from a list of available bootable volumes. You can add Linux- or Windows-based volumes to the list.

Procedure
  1. In the web console, navigate to VirtualizationCatalog.

    The InstanceTypes tab opens by default.

  2. Select either of the following options:

    • Select a suitable bootable volume from the list. If the list is truncated, click the Show all button to display the entire list.

      The bootable volume table lists only those volumes in the openshift-virtualization-os-images namespace that have the instancetype.kubevirt.io/default-preference label.

      • 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 to use an existing persistent volume claim (PVC), a volume snapshot, or a containerDisk volume. click Save.

      Logos of operating systems that are not available in the cluster are shown at the bottom of the list. You can add a volume for the required operating system by clicking the Add volume link.

      In addition, there is a link to the Create a Windows boot source quick start. The same link appears in a popover if you hover the pointer over the question mark icon next to the Select volume to boot from line.

      Immediately after you install the environment or when the environment is disconnected, the list of volumes to boot from is empty. In that case, three operating system logos are displayed: Windows, RHEL, and Linux. You can add a new volume that meets your requirements by clicking the Add volume button.

  3. click an instance type tile and select the resource size appropriate for your workload.

  4. Optional: Choose the virtual machine details, including the VM’s name, that apply to the volume you are booting from:

    • For a Linux-based volume, follow these steps to configure SSH:

      1. 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.

      2. Select one of the following options:

        • Use existing: Select a secret from the secrets list.

        • Add new: Follow these steps:

          1. Browse to the public SSH key file or paste the file in the key field.

          2. Enter the secret name.

          3. Optional: Select Automatically apply this key to any new VirtualMachine you create in this project.

      3. click Save.

    • For a Windows volume, follow either of these set of steps to configure sysprep options:

      • If you have not already added sysprep options for the Windows volume, follow these steps:

        1. click the edit icon beside Sysprep in the VirtualMachine details section.

        2. Add the Autoattend.xml answer file.

        3. Add the Unattend.xml answer file.

        4. click Save.

      • If you want to use existing sysprep options for the Windows volume, follow these steps:

        1. click Attach existing sysprep.

        2. Enter the name of the existing sysprep Unattend.xml answer file.

        3. click Save.

  5. Optional: If you are creating a Windows VM, you can mount a Windows driver disk:

    1. click the Customize VirtualMachine button.

    2. On the VirtualMachine details page, click Storage.

    3. Select the Mount Windows drivers disk checkbox.

  6. 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.

  7. click Create VirtualMachine.

After the VM is created, you can monitor the status on the VirtualMachine details page.