Initiating and canceling live migration

You can initiate the live migration of a virtual machine (VM) to another node by using the OKD web console or the command line.

You can cancel a live migration by using the web console or the command line. The VM remains on its original node.

You can also initiate and cancel live migration by using the virtctl migrate <vm_name> and virtctl migrate-cancel <vm_name> commands.

Initiating live migration

Initiating live migration by using the web console

You can live migrate a running virtual machine (VM) to a different node in the cluster by using the OKD web console.

The Migrate action is visible to all users but only cluster administrators can initiate a live migration.

Prerequisites

  • The VM must be migratable.

  • If the VM is configured with a host model CPU, the cluster must have an available node that supports the CPU model.

Procedure

  1. Navigate to VirtualizationVirtualMachines in the web console.

  2. Select Migrate from the Options menu kebab beside a VM.

  3. Click Migrate.

Initiating live migration by using the command line

You can initiate the live migration of a running virtual machine (VM) by using the command line to create a VirtualMachineInstanceMigration object for the VM.

Procedure

  1. Create a VirtualMachineInstanceMigration manifest for the VM that you want to migrate:

    1. apiVersion: kubevirt.io/v1
    2. kind: VirtualMachineInstanceMigration
    3. metadata:
    4. name: <migration_name>
    5. spec:
    6. vmiName: <vm_name>
  2. Create the object by running the following command:

    1. $ oc create -f <migration_name>.yaml

    The VirtualMachineInstanceMigration object triggers a live migration of the VM. This object exists in the cluster for as long as the virtual machine instance is running, unless manually deleted.

Verification

  • Obtain the VM status by running the following command:

    1. $ oc describe vmi <vm_name>

    Example output

    1. # ...
    2. Status:
    3. Conditions:
    4. Last Probe Time: <nil>
    5. Last Transition Time: <nil>
    6. Status: True
    7. Type: LiveMigratable
    8. Migration Method: LiveMigration
    9. Migration State:
    10. Completed: true
    11. End Timestamp: 2018-12-24T06:19:42Z
    12. Migration UID: d78c8962-0743-11e9-a540-fa163e0c69f1
    13. Source Node: node2.example.com
    14. Start Timestamp: 2018-12-24T06:19:35Z
    15. Target Node: node1.example.com
    16. Target Node Address: 10.9.0.18:43891
    17. Target Node Domain Detected: true

Canceling live migration

Canceling live migration by using the web console

You can cancel the live migration of a virtual machine (VM) by using the OKD web console.

Procedure

  1. Navigate to VirtualizationVirtualMachines in the web console.

  2. Select Cancel Migration on the Options menu kebab beside a VM.

Canceling live migration by using the command line

Cancel the live migration of a virtual machine by deleting the VirtualMachineInstanceMigration object associated with the migration.

Procedure

  • Delete the VirtualMachineInstanceMigration object that triggered the live migration, migration-job in this example:

    1. $ oc delete vmim migration-job

Additional resources