Configuring live migration

You can configure live migration settings to ensure that the migration processes do not overwhelm the cluster.

You can configure live migration policies to apply different migration configurations to groups of virtual machines (VMs).

Live migration settings

You can configure the following live migration settings:

Configuring live migration limits and timeouts

Configure live migration limits and timeouts for the cluster by updating the HyperConverged custom resource (CR), which is located in the openshift-cnv namespace.

Procedure

  • Edit the HyperConverged CR and add the necessary live migration parameters:

    1. $ oc edit hyperconverged kubevirt-hyperconverged -n kubevirt-hyperconverged

    Example configuration file

    1. apiVersion: hco.kubevirt.io/v1beta1
    2. kind: HyperConverged
    3. metadata:
    4. name: kubevirt-hyperconverged
    5. namespace: kubevirt-hyperconverged
    6. spec:
    7. liveMigrationConfig:
    8. bandwidthPerMigration: 64Mi (1)
    9. completionTimeoutPerGiB: 800 (2)
    10. parallelMigrationsPerCluster: 5 (3)
    11. parallelOutboundMigrationsPerNode: 2 (4)
    12. progressTimeout: 150 (5)
    1Bandwidth limit of each migration, where the value is the quantity of bytes per second. For example, a value of 2048Mi means 2048 MiB/s. Default: 0, which is unlimited.
    2The migration is canceled if it has not completed in this time, in seconds per GiB of memory. For example, a VM with 6GiB memory times out if it has not completed migration in 4800 seconds. If the Migration Method is BlockMigration, the size of the migrating disks is included in the calculation.
    3Number of migrations running in parallel in the cluster. Default: 5.
    4Maximum number of outbound migrations per node. Default: 2.
    5The migration is canceled if memory copy fails to make progress in this time, in seconds. Default: 150.

You can restore the default value for any spec.liveMigrationConfig field by deleting that key/value pair and saving the file. For example, delete progressTimeout: <value> to restore the default progressTimeout: 150.

Live migration policies

You can create live migration policies to apply different migration configurations to groups of VMs that are defined by VM or project labels.

You can create live migration policies by using the web console.

Creating a live migration policy by using the command line

You can create a live migration policy by using the command line. A live migration policy is applied to selected virtual machines (VMs) by using any combination of labels:

  • VM labels such as size, os, or gpu

  • Project labels such as priority, bandwidth, or hpc-workload

For the policy to apply to a specific group of VMs, all labels on the group of VMs must match the labels of the policy.

If multiple live migration policies apply to a VM, the policy with the greatest number of matching labels takes precedence.

If multiple policies meet this criteria, the policies are sorted by alphabetical order of the matching label keys, and the first one in that order takes precedence.

Procedure

  1. Create a MigrationPolicy object as in the following example:

    1. apiVersion: migrations.kubevirt.io/v1alpha1
    2. kind: MigrationPolicy
    3. metadata:
    4. name: <migration_policy>
    5. spec:
    6. selectors:
    7. namespaceSelector: (1)
    8. hpc-workloads: "True"
    9. xyz-workloads-type: ""
    10. virtualMachineInstanceSelector: (2)
    11. workload-type: "db"
    12. operating-system: ""
    1Specify project labels.
    2Specify VM labels.
  2. Create the migration policy by running the following command:

    1. $ oc create migrationpolicy -f <migration_policy>.yaml

Additional resources