$ virtctl create vm --instancetype <my_instancetype> --preference <my_preference>
You can specify an instance type, a preference, or both to define a set of workload sizing and runtime characteristics for reuse across multiple VMs.
Specify instance types and preferences by using flags.
You must have an instance type, preference, or both on the cluster.
To specify an instance type when creating a VM, use the --instancetype
flag. To specify a preference, use the --preference
flag. The following example includes both flags:
$ virtctl create vm --instancetype <my_instancetype> --preference <my_preference>
Optional: To specify a namespaced instance type or preference, include the kind
in the value passed to the --instancetype
or --preference
flag command. The namespaced instance type or preference must be in the same namespace you are creating the VM in. The following example includes flags for a namespaced instance type and a namespaced preference:
$ virtctl create vm --instancetype virtualmachineinstancetype/<my_instancetype> --preference virtualmachinepreference/<my_preference>
Inferring instance types, preferences, or both is enabled by default, and the inferFromVolumeFailure
policy of the inferFromVolume
attribute is set to Ignore
. When inferring from the boot volume, errors are ignored, and the VM is created with the instance type and preference left unset.
However, when flags are applied, the inferFromVolumeFailure
policy defaults to Reject
. When inferring from the boot volume, errors result in the rejection of the creation of that VM.
You can use the --infer-instancetype
and --infer-preference
flags to infer which instance type, preference, or both to use to define the workload sizing and runtime characteristics of a VM.
You have installed the virtctl
tool.
To explicitly infer instance types from the volume used to boot the virtual machine, use the --infer-instancetype
flag. To explicitly infer preferences, use the --infer-preference
flag. The following command includes both flags:
$ virtctl create vm --volume-import type:pvc,src:my-ns/my-pvc --infer-instancetype --infer-preference
Use the following labels on your PVC, data source, or data volume to instruct the inference mechanism which instance type, preference, or both to use when trying to boot from a volume.
A cluster-wide instance type: instancetype.kubevirt.io/default-instancetype
label.
A namespaced instance type: instancetype.kubevirt.io/default-instancetype-kind
label. Defaults to the VirtualMachineClusterInstancetype
label if left empty.
A cluster-wide preference: instancetype.kubevirt.io/default-preference
label.
A namespaced preference: instancetype.kubevirt.io/default-preference-kind
label. Defaults to VirtualMachineClusterPreference
label, if left empty.
You must have an instance type, preference, or both on the cluster.
To apply a label to a data source, use oc label
. The following command applies a label that points to a cluster-wide instance type:
$ oc label DataSource foo instancetype.kubevirt.io/default-instancetype=<my_instancetype>