×

You can configure CPU models for your virtual machines at both the cluster level and individual VM level. Set a cluster-wide default CPU model to automatically apply to all new VMs, or configure a specific CPU model for individual VMs to override the cluster default.

Configure the default CPU model

Define a cluster-wide default CPU model. Every new virtual machine (VM) that does not specify its own CPU model uses the default, and runs only on nodes that support it.

When you set a cluster-wide default CPU model:

  • Every new virtual machine (VM) that does not have an explicit CPU model defined receives a node selector for the chosen CPU model.

  • Only nodes labeled with cpu-model.node.kubevirt.io/<cpuModel> are eligible to run VMs using the default model.

  • Nodes that do not support the selected CPU model are not considered during VM scheduling.

The defaultCPUModel is case sensitive and must match a CPU model supported by nodes in your cluster.

A CPU model configured at the VM level always takes precedence over the cluster-wide default CPU model.

Prerequisites
  • Install the OpenShift CLI (oc).

Procedure
  1. Open the HyperConverged CR by running the following command:

    $ oc edit hyperconvergeds.v1beta1.hco.kubevirt.io kubevirt-hyperconverged -n kubevirt-hyperconverged
  2. Add the defaultCPUModel field to the CR and set the value to the name of a CPU model that exists in the cluster:

    apiVersion: hco.kubevirt.io/v1beta1
    kind: HyperConverged
    metadata:
     name: kubevirt-hyperconverged
     namespace: kubevirt-hyperconverged
    spec:
      defaultCPUModel: "EPYC-IBPB"

    where:

    EPYC-IBPB

    Specifies a CPU model that is supported by nodes in your cluster.

  3. Apply the YAML file to your cluster.

Configure a CPU model for a single VM

Set a named CPU model on a single virtual machine (VM) when that VM needs a different CPU type from the cluster-wide default. A per-VM model always takes precedence over the default.

The VM CPU model depends on the availability of CPU models within the VM and the cluster.

  • If the VM does not have a defined CPU model, the defaultCPUModel is automatically set using the CPU model defined at the cluster-wide level.

  • If both the VM and the cluster have a defined CPU model, the VM’s CPU model takes precedence.

  • If neither the VM nor the cluster have a defined CPU model, the host-model is automatically set using the CPU model defined at the host level.

Prerequisites
  • Install the OpenShift CLI (oc).

Procedure
  1. To configure a named CPU model for a specific VM, edit the VirtualMachine custom resource (CR):

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: myvm
    spec:
      template:
        spec:
          domain:
            cpu:
              model: Conroe
    • spec.template.spec.domain.cpu.model defines the named CPU model for the VM.

  2. Apply the CR to your cluster.