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.
TOC
ConceptsCommon instance typesView Instance Types and PreferencesCreate an Instance Type or PreferenceUpdate or Delete an Instance Type or PreferenceHow a Virtual Machine Shows Its Instance TypeUsing YAMLConcepts
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
kindmeans 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 (
resourcesCPU and memory,domain.cpusockets / 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.
Common preferences are named after the guest operating system, for example centos.stream9, ubuntu, rhel.9 or windows.2k22.virtio.
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:
View Instance Types and Preferences
-
Enter Administrator to manage cluster-scoped objects, or Container Platform to manage the objects of the current namespace.
-
In the left navigation bar, click Virtualization > Specifications.
-
Select the Instance Type or Preference tab.
-
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
-
On the Specifications page, select the Instance Type or Preference tab and click Create Instance Type or Create Preference.
-
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:
Preference:
-
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:
A namespaced instance type with dedicated CPUs and 1Gi hugepages (the nodes must provide 1Gi hugepages):
An instance type with hotplug ceilings, so that a running virtual machine can grow up to 8 vCPUs and 32Gi of memory:
A cluster-wide preference for Linux guests with virtio devices:
A namespaced preference for a Windows guest with UEFI secure boot and a virtual TPM:
Apply and list them:
Find the virtual machines that reference an instance type, and the copy a virtual machine resolved:
The form covers the common settings. These settings are set in YAML only:
To use an instance type and a preference in a virtual machine, see Creating Virtual Machines.