Instance Types and Preferences

An instance type is a reusable object that declares the size of a virtual machine: the guest CPU count and memory, and optionally dedicated CPUs, hugepages, hotplug ceilings, GPUs, host devices and node placement. A preference is a reusable object that declares how a guest operating system prefers its virtual hardware — for example the disk bus, the network interface model, the firmware and the clock — and the minimum resources such a guest needs.

Referencing an instance type and a preference is the recommended way to size a new virtual machine:

  • The size is defined once and shared. Every virtual machine that references the same instance type has the same size, and resizing a virtual machine means pointing it at another instance type.
  • A preference applies the settings an operating system works best with, without editing each virtual machine.
  • A virtual machine keeps running from the copy of the instance type it started with, so editing a shared instance type never changes running workloads by surprise.

Setting CPU and memory directly in the virtual machine (a machine model) is still available; see Creating Virtual Machines. To move an existing virtual machine from a machine model to an instance type, see Migrate to Instance Type.

Concepts

KindScopeManaged in
VirtualMachineClusterInstancetypeClusterAdministrator > Virtualization > Specifications
VirtualMachineClusterPreferenceClusterAdministrator > Virtualization > Specifications
VirtualMachineInstancetypeNamespaceContainer Platform > Virtualization > Specifications
VirtualMachinePreferenceNamespaceContainer Platform > Virtualization > Specifications

All four kinds belong to the API group instancetype.kubevirt.io/v1beta1.

  • Scope: a virtual machine can reference a cluster-scoped object from any namespace, and a namespaced object only from its own namespace. A reference that omits kind means the cluster-scoped kind.
  • Revisions: when a virtual machine first resolves its instance type or preference, the platform stores a copy of the object (a ControllerRevision) in the namespace of the virtual machine and records it in the virtual machine's status. The virtual machine keeps using that copy: updating or deleting the object later does not change virtual machines that already resolved it. Pointing a virtual machine at a different object records a new copy.
  • Instance type settings cannot be overridden: a virtual machine that references an instance type must not set its own CPU count or memory (resources CPU and memory, domain.cpu sockets / cores / threads, domain.memory.guest), nor any other setting the instance type also sets. Such a virtual machine is rejected.
  • Provided by product: the platform installs a set of common instance types and preferences on each virtualization cluster. They are marked Provided by product, are maintained by the virtualization operator, and cannot be updated or deleted. Create your own objects for other sizes and settings.

Common instance types

Common instance types are named <series>.<size>, for example u1.medium. Sizes whose name ends in 1gi use 1Gi hugepages instead of 2Mi hugepages.

SeriesIntended forCharacteristics
u1General-purpose workloadsGuest CPU and memory only
o1General-purpose workloads with overcommitted memoryMemory overcommitted by 50%
d1Consistent, predictable performanceDedicated CPUs, isolated emulator thread
cx1Compute-intensive workloadsDedicated CPUs, isolated emulator thread, guest NUMA mapped to the host, hugepages
m1Memory-intensive workloadsHugepages
n1Network-intensive (DPDK) workloadsDedicated CPUs, isolated emulator thread, 1Gi hugepages
rt1Realtime workloadsDedicated CPUs, isolated emulator thread, guest NUMA mapped to the host, realtime, 1Gi hugepages

Common preferences are named after the guest operating system, for example centos.stream9, ubuntu, rhel.9 or windows.2k22.virtio.

WARNING

An instance type that sets a hugepage size (the cx1, m1, n1 and rt1 series, or your own) needs nodes that have preallocated hugepages of that size — at least the guest memory, on a single node. On a cluster without them, a virtual machine that references such an instance type is created but cannot start: it stays Abnormal, and its virt-launcher pod reports Insufficient hugepages-2Mi (or hugepages-1Gi). The Hugepage Size column of the list and the instance type picker show which instance types need hugepages. Check what the nodes provide with:

kubectl get nodes -o custom-columns='NODE:.metadata.name,HUGEPAGES_2Mi:.status.allocatable.hugepages-2Mi,HUGEPAGES_1Gi:.status.allocatable.hugepages-1Gi'

View Instance Types and Preferences

  1. Enter Administrator to manage cluster-scoped objects, or Container Platform to manage the objects of the current namespace.

  2. In the left navigation bar, click Virtualization > Specifications.

  3. Select the Instance Type or Preference tab.

    ColumnDescription
    SourceProvided by product for a common object, Custom otherwise.
    Guest CPU / Guest MemoryThe size an instance type gives a virtual machine.
    Hugepage SizeThe hugepage size an instance type requires, or - when it uses none.
    Preferred SettingsThe number of settings a preference declares.
  4. Click a name to open the detail page:

    • Instance Type Settings / Preference Settings show only the settings the object declares. Each preferred device, firmware, clock and feature setting of a preference is its own row, for example Preferred Disk Bus and Preferred Interface Model.
    • The Virtual Machines tab lists the virtual machines that reference the object.
    • The YAML tab shows the complete object.

Create an Instance Type or Preference

  1. On the Specifications page, select the Instance Type or Preference tab and click Create Instance Type or Create Preference.

  2. Fill in the form, or switch to YAML. Settings that are not in the form can be set in YAML; see Using YAML.

    Instance type:

    ParameterDescription
    NameCannot be changed after creation.
    Guest CPURequired. The number of vCPUs the guest sees.
    Guest MemoryRequired. A quantity such as 8Gi.
    Dedicated CPU PlacementPins each vCPU to a physical CPU of the node.
    Isolated Emulator ThreadRuns the emulator thread on its own physical CPU; used with dedicated CPUs.
    Hotplug Socket CeilingThe largest number of CPU sockets a running virtual machine can hot-plug up to.
    Hotplug Memory CeilingThe largest memory a running virtual machine can hot-plug up to.
    Hugepage SizeBacks the guest memory with hugepages of this size (for example 2Mi or 1Gi); the nodes must provide them.
    GPUs / Host DevicesDevices passed through to the virtual machine, each as a name and a device name.
    Node SelectorLabels a node must carry to run the virtual machine.
    Labels / AnnotationsMetadata of the instance type object.

    Preference:

    ParameterDescription
    Preferred CPU TopologyHow the guest CPU count is laid out, for example as sockets or as cores.
    Preferred Disk Bus / Preferred CD-ROM BusFor example virtio, sata or scsi.
    Preferred Interface ModelFor example virtio or e1000e.
    Preferred Input Bus / Preferred Input TypeFor example usb and tablet.
    Preferred TPMAttaches a virtual TPM.
    Preferred Graphics Device / Preferred Serial ConsoleWhether a graphics device and a serial console are attached.
    Preferred EFI Firmware / Preferred Secure Boot / Preferred BIOS FirmwareThe boot firmware. Secure boot needs EFI firmware and the SMM feature.
    Preferred SMM FeatureEnables System Management Mode.
    Preferred Machine TypeFor example q35.
    Preferred Storage ClassThe storage class for the virtual machine's volumes.
    Preferred ArchitectureFor example amd64.
    Required Guest CPU / Required Guest Memory / Required ArchitectureThe minimum a virtual machine that references this preference must provide; a smaller virtual machine is rejected.
  3. Click Create.

A preference applies its settings only where the virtual machine leaves them unset; a value the virtual machine sets itself is kept.

Update or Delete an Instance Type or Preference

  • To update, click ⋮ > Update in the list or Update on the detail page. The name cannot be changed. If virtual machines reference the object, they are listed before you save: each keeps the copy recorded in its status, and the change applies to virtual machines that resolve the object from then on.
  • To delete, click ⋮ > Delete. The confirmation lists the virtual machines that reference the object. Those already started keep their recorded copy; those not started yet fail to start until they reference an existing object.
  • Objects marked Provided by product offer View YAML only.

How a Virtual Machine Shows Its Instance Type

  • In the virtual machine list, the Resources column shows Instance Type and its name, Machine Model, or Sizing undetermined.
  • On the virtual machine detail page, the Instance Type and Preference rows show the requested object, the object it resolved to with the recorded revision, and — when the reference cannot be resolved — the reason, such as FailedFindInstancetype.

Using YAML

A cluster-wide instance type:

apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachineClusterInstancetype
metadata:
  name: standard.4c8g
spec:
  cpu:
    guest: 4          # required: vCPUs of the guest
  memory:
    guest: 8Gi        # required: memory of the guest

A namespaced instance type with dedicated CPUs and 1Gi hugepages (the nodes must provide 1Gi hugepages):

apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachineInstancetype
metadata:
  name: db.8c32g
  namespace: demo
spec:
  cpu:
    guest: 8
    dedicatedCPUPlacement: true
    isolateEmulatorThread: true
  memory:
    guest: 32Gi
    hugepages:
      pageSize: 1Gi

An instance type with hotplug ceilings, so that a running virtual machine can grow up to 8 vCPUs and 32Gi of memory:

apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachineClusterInstancetype
metadata:
  name: elastic.2c8g
spec:
  cpu:
    guest: 2
    maxSockets: 8
  memory:
    guest: 8Gi
    maxGuest: 32Gi

A cluster-wide preference for Linux guests with virtio devices:

apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachineClusterPreference
metadata:
  name: linux-virtio
spec:
  devices:
    preferredDiskBus: virtio
    preferredInterfaceModel: virtio
  requirements:       # the smallest virtual machine this guest runs on
    cpu:
      guest: 1
    memory:
      guest: 2Gi

A namespaced preference for a Windows guest with UEFI secure boot and a virtual TPM:

apiVersion: instancetype.kubevirt.io/v1beta1
kind: VirtualMachinePreference
metadata:
  name: windows-uefi
  namespace: demo
spec:
  cpu:
    preferredCPUTopology: sockets
  devices:
    preferredDiskBus: sata
    preferredInterfaceModel: e1000e
    preferredTPM:
      persistent: true
  firmware:
    preferredUseEfi: true
    preferredUseSecureBoot: true
  features:
    preferredSmm: {}

Apply and list them:

kubectl apply -f instancetype.yaml
kubectl get virtualmachineclusterinstancetypes
kubectl get virtualmachineinstancetypes -n demo
kubectl get virtualmachineclusterpreferences
kubectl get virtualmachinepreferences -n demo

Find the virtual machines that reference an instance type, and the copy a virtual machine resolved:

kubectl get vm -A -o jsonpath='{range .items[?(@.spec.instancetype.name=="standard.4c8g")]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}'

kubectl get vm web-01 -n demo -o jsonpath='{.status.instancetypeRef}'
# {"controllerRevisionRef":{"name":"web-01-standard.4c8g-v1beta1-<uid>-1"},"kind":"VirtualMachineClusterInstancetype","name":"standard.4c8g"}

The form covers the common settings. These settings are set in YAML only:

KindSettings
Instance typespec.annotations, spec.cpu.model, spec.cpu.numa, spec.cpu.realtime, spec.memory.overcommitPercent, spec.ioThreads, spec.ioThreadsPolicy, spec.launchSecurity, spec.schedulerName
Preferencespec.annotations, spec.clock, spec.cpu.preferredCPUFeatures, spec.cpu.spreadOptions, spec.features other than preferredSmm, spec.firmware.preferredEfi, spec.firmware.preferredUseBiosSerial, other spec.devices settings (for example preferredDiskDedicatedIoThread, preferredBlockMultiQueue, preferredRng), spec.preferSpreadSocketToCoreRatio, spec.preferredSubdomain, spec.preferredTerminationGracePeriodSeconds

To use an instance type and a preference in a virtual machine, see Creating Virtual Machines.