Live migration for virtual machines

High availability of virtual machines can be achieved by live migration as the virtual machine continues to be operative and accessible. Live migration is the process of moving a virtual machine that is running from one physical host to another seamlessly without interrupting the workload.

Before you begin

In the openshift-cnv namespace, edit the HyperConverged CR and add the necessary live migration parameters:
oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
Example:

apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
  name: kubevirt-hyperconverged
  namespace: openshift-cnv
spec:
  liveMigrationConfig:
    bandwidthPerMigration: 64Mi 
    completionTimeoutPerGiB: 800 
    parallelMigrationsPerCluster: 5 
    parallelOutboundMigrationsPerNode: 2 
    progressTimeout: 150 

About this task

Manually initiate a live migration of a virtual machine instance to another node using either the web console or the CLI. To know more about live migration, see Red Hat documentation.

Live migration from the user interface

Procedure

  1. As an administrator user, log in to the OpenShift® Container Platform console.
  2. Go to Virtualization > VirtualMachines.
  3. Search for the virtual machine that you want to migrate.
  4. Click the ellipses overflow menu of the virtual machine and select Migrate or you can go to the virtual machine Overview screen and select Migrate Virtual Machine from the Actions menu.
    The status of the virtual machine changes from Running to Migrating.
  5. After the migration completes, in the virtual machine details page, check the hosting node name to confirm the migration.

Live migration from the command line

Procedure

  1. Create a migrate.yaml configuration file for the virtual machine instance to migrate.
    migrate.yaml:
    
    apiVersion: kubevirt.io/v1
    kind: VirtualMachineInstanceMigration
    metadata:
      name: {{ vm_name }}-migrate
      namespace: {{ namespace }}
    spec:
      vmiName: {{ vm_name }}
    Example:
    
    apiVersion: kubevirt.io/v1
    kind: VirtualMachineInstanceMigration
    metadata:
      name: migration-job
      namespace: openshift-cnv
    spec:
      vmiName: icsvm-storage-gui-kocmddajec
  2. Apply the YAML file to initiate the migration.
    oc apply migrate.yml