A virtual machine (VM) class defines what the project owner doesn’t configure: the virtual CPU model, the allowed combinations of cores and memory, and the nodes where a VM can run. These rules are described by the VirtualMachineClass resource, which you use to control how project workloads are distributed across cluster nodes.

On the initial installation, the module creates the generic class with the Nehalem CPU model. This model is old but supported by any modern CPU, so VMs of this class start on any cluster node and migrate between nodes without restrictions.

The generic class matches a CPU with the smallest instruction set, so it isn’t suitable for production workloads.

Once all nodes are added to the cluster and configured, create at least one class with the Discovery CPU type. Deckhouse Platform (DP) selects an instruction set available on all nodes at once, so virtual machines can make fuller use of the CPUs while still being able to migrate between nodes. The instruction set is fixed when the resource is created and doesn’t change as nodes are added or removed.

For an example of such a class, see vCPU Discovery configuration example.

Classes exist at the cluster level. To list them, run the following command:

d8 k get virtualmachineclass

Example output:

NAME      PHASE   ISDEFAULT   AGE
generic   Ready               6d1h

In any class, you can change everything except the .spec.cpu block, because the CPU model is fixed when the resource is created. You can both modify and delete the generic class, but it won’t be created again, because the module adds it only on the initial installation.

The project owner specifies the class in the .spec.virtualMachineClassName parameter of a virtual machine:

apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualMachine
metadata:
  name: linux-vm
spec:
  virtualMachineClassName: generic # Name of the VirtualMachineClass resource.
  # ...

Default VirtualMachineClass

You can designate one of the classes as the default. DP inserts its name into the .spec.virtualMachineClassName parameter if the project owner doesn’t specify a class.

The default class is marked with the virtualmachineclass.virtualization.deckhouse.io/is-default-class annotation set to true. A cluster can have only one such class, so to designate a new one, first remove the annotation from the current one.

Don’t add the annotation to the generic class, because a module update can remove it. Create your own class and designate it as the default instead.

  1. Check which classes exist in the cluster:

    d8 k get vmclass
    

    Example output with no default class:

    NAME                      PHASE   ISDEFAULT   AGE
    generic                   Ready               1d
    host-passthrough-custom   Ready               1d
    
  2. Designate the default class:

    d8 k annotate vmclass host-passthrough-custom virtualmachineclass.virtualization.deckhouse.io/is-default-class=true
    
  3. Verify that the annotation is set:

    d8 k get vmclass
    

    Example output:

    NAME                      PHASE   ISDEFAULT   AGE
    generic                   Ready               1d
    host-passthrough-custom   Ready   true        1d
    

From now on, virtual machines created without a class get the host-passthrough-custom class.

VirtualMachineClass settings

A class consists of three blocks, each responsible for its own group of settings:

  • Using the CLI
  • Using the web interface

Describe the class in a VirtualMachineClass resource:

apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualMachineClass
metadata:
  name: <VMCLASS_NAME>
  # The annotation designates the class as the default one. It's optional.
  # annotations:
  #   virtualmachineclass.virtualization.deckhouse.io/is-default-class: "true"
spec:
  # Virtual CPU parameters. The block is required and can't be changed after the resource is created.
  cpu: ...

  # Rules for placing virtual machines on nodes. The block is optional.
  # Changes apply to all VMs of this class.
  nodeSelector: ...

  # Resource allocation policy for virtual machines. The block is optional.
  # Changes apply to all VMs of this class.
  sizingPolicies: ...

Where <VMCLASS_NAME> is the name of the class you’re creating.

  1. Go to the System tab, then to VirtualizationVM classes.
  2. Click Create.
  3. In the form that opens, enter the VM class name in the Name field.

The blocks are described separately in the following sections.

Additional resources