This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Este contenido no está disponible en el idioma seleccionado.
Chapter 10. Live migration
10.1. Virtual machine live migration Copiar enlaceEnlace copiado en el portapapeles!
10.1.1. Understanding live migration Copiar enlaceEnlace copiado en el portapapeles!
Live migration is the process of moving a running virtual machine instance (VMI) to another node in the cluster without interrupting the virtual workload or access. If a VMI uses the LiveMigrate
eviction strategy, it automatically migrates when the node that the VMI runs on is placed into maintenance mode. You can also manually start live migration by selecting a VMI to migrate.
Virtual machines must have a persistent volume claim (PVC) with a shared ReadWriteMany (RWX) access mode to be live migrated.
Live migration is supported for virtual machines that are attached to an SR-IOV network interface only if the sriovLiveMigration
feature gate is enabled in the HyperConverged Cluster custom resource (CR). When the spec.featureGates.sriovLiveMigration
field is set to true
, the virt-launcher
pod runs with the SYS_RESOURCE
capability. This might degrade its security.
10.1.2. Updating access mode for live migration Copiar enlaceEnlace copiado en el portapapeles!
For live migration to function properly, you must use the ReadWriteMany (RWX) access mode. Use this procedure to update the access mode, if needed.
Procedure
To set the RWX access mode, run the following
oc patch
command:oc patch -n openshift-cnv \ cm kubevirt-storage-class-defaults \ -p '{"data":{"'$<STORAGE_CLASS>'.accessMode":"ReadWriteMany"}}'
$ oc patch -n openshift-cnv \ cm kubevirt-storage-class-defaults \ -p '{"data":{"'$<STORAGE_CLASS>'.accessMode":"ReadWriteMany"}}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.2. Live migration limits and timeouts Copiar enlaceEnlace copiado en el portapapeles!
Apply live migration limits and timeouts so that migration processes do not overwhelm the cluster. Configure these settings by editing the HyperConverged
custom resource (CR).
10.2.1. Configuring live migration limits and timeouts Copiar enlaceEnlace copiado en el portapapeles!
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.oc edit hco -n openshift-cnv kubevirt-hyperconverged
$ oc edit hco -n openshift-cnv kubevirt-hyperconverged
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example configuration file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- In this example, the
spec.liveMigrationConfig
array contains the default values for each field.
NoteYou can restore the default value for any
spec.liveMigrationConfig
field by deleting that key/value pair and saving the file. For example, deleteprogressTimeout: <value>
to restore the defaultprogressTimeout: 150
.
10.2.2. Cluster-wide live migration limits and timeouts Copiar enlaceEnlace copiado en el portapapeles!
Parameter | Description | Default |
---|---|---|
| Number of migrations running in parallel in the cluster. | 5 |
| Maximum number of outbound migrations per node. | 2 |
| Bandwidth limit of each migration, in MiB/s. | 0 [1] |
|
The migration is canceled if it has not completed in this time, in seconds per GiB of memory. For example, a virtual machine instance with 6GiB memory times out if it has not completed migration in 4800 seconds. If the | 800 |
| The migration is canceled if memory copy fails to make progress in this time, in seconds. | 150 |
-
The default value of
0
is unlimited.
10.3. Migrating a virtual machine instance to another node Copiar enlaceEnlace copiado en el portapapeles!
Manually initiate a live migration of a virtual machine instance to another node using either the web console or the CLI.
10.3.1. Initiating live migration of a virtual machine instance in the web console Copiar enlaceEnlace copiado en el portapapeles!
Migrate a running virtual machine instance to a different node in the cluster.
The Migrate Virtual Machine action is visible to all users but only admin users can initiate a virtual machine migration.
Procedure
-
In the OpenShift Virtualization console, click Workloads
Virtualization from the side menu. - Click the Virtual Machines tab.
You can initiate the migration from this screen, which makes it easier to perform actions on multiple virtual machines in the one screen, or from the Virtual Machine Overview screen where you can view comprehensive details of the selected virtual machine:
-
Click the Options menu
at the end of virtual machine and select Migrate Virtual Machine.
-
Click the virtual machine name to open the Virtual Machine Overview screen and click Actions
Migrate Virtual Machine.
-
Click the Options menu
- Click Migrate to migrate the virtual machine to another node.
10.3.2. Initiating live migration of a virtual machine instance in the CLI Copiar enlaceEnlace copiado en el portapapeles!
Initiate a live migration of a running virtual machine instance by creating a VirtualMachineInstanceMigration
object in the cluster and referencing the name of the virtual machine instance.
Procedure
Create a
VirtualMachineInstanceMigration
configuration file for the virtual machine instance to migrate. For example,vmi-migrate.yaml
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the object in the cluster by running the following command:
oc create -f vmi-migrate.yaml
$ oc create -f vmi-migrate.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The VirtualMachineInstanceMigration
object triggers a live migration of the virtual machine instance. This object exists in the cluster for as long as the virtual machine instance is running, unless manually deleted.
10.4. Monitoring live migration of a virtual machine instance Copiar enlaceEnlace copiado en el portapapeles!
You can monitor the progress of a live migration of a virtual machine instance from either the web console or the CLI.
10.4.1. Monitoring live migration of a virtual machine instance in the web console Copiar enlaceEnlace copiado en el portapapeles!
For the duration of the migration, the virtual machine has a status of Migrating. This status is displayed in the Virtual Machines tab or in the Virtual Machine Overview screen for the migrating virtual machine.
Procedure
-
In the OpenShift Virtualization console, click Workloads
Virtualization from the side menu. - Click the Virtual Machines tab.
- Select a virtual machine to open the Virtual Machine Overview screen.
10.4.2. Monitoring live migration of a virtual machine instance in the CLI Copiar enlaceEnlace copiado en el portapapeles!
The status of the virtual machine migration is stored in the Status
component of the VirtualMachineInstance
configuration.
Procedure
Use the
oc describe
command on the migrating virtual machine instance:oc describe vmi vmi-fedora
$ oc describe vmi vmi-fedora
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.5. Cancelling the live migration of a virtual machine instance Copiar enlaceEnlace copiado en el portapapeles!
Cancel the live migration so that the virtual machine instance remains on the original node.
You can cancel a live migration from either the web console or the CLI.
10.5.1. Cancelling live migration of a virtual machine instance in the web console Copiar enlaceEnlace copiado en el portapapeles!
You can cancel a live migration of the virtual machine instance using the Options menu
found on each virtual machine in the Virtualization
Procedure
-
In the OpenShift Virtualization console, click Workloads
Virtualization from the side menu. - Click the Virtual Machines tab.
You can cancel the migration from this screen, which makes it easier to perform actions on multiple virtual machines, or from the Virtual Machine Overview screen where you can view comprehensive details of the selected virtual machine:
-
Click the Options menu
at the end of virtual machine and select Cancel Virtual Machine Migration.
-
Select a virtual machine name to open the Virtual Machine Overview screen and click Actions
Cancel Virtual Machine Migration.
-
Click the Options menu
- Click Cancel Migration to cancel the virtual machine live migration.
10.5.2. Cancelling live migration of a virtual machine instance in the CLI Copiar enlaceEnlace copiado en el portapapeles!
Cancel the live migration of a virtual machine instance by deleting the VirtualMachineInstanceMigration
object associated with the migration.
Procedure
Delete the
VirtualMachineInstanceMigration
object that triggered the live migration,migration-job
in this example:oc delete vmim migration-job
$ oc delete vmim migration-job
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.6. Configuring virtual machine eviction strategy Copiar enlaceEnlace copiado en el portapapeles!
The LiveMigrate
eviction strategy ensures that a virtual machine instance is not interrupted if the node is placed into maintenance or drained. Virtual machines instances with this eviction strategy will be live migrated to another node.
10.6.1. Configuring custom virtual machines with the LiveMigration eviction strategy Copiar enlaceEnlace copiado en el portapapeles!
You only need to configure the LiveMigration
eviction strategy on custom virtual machines. Common templates have this eviction strategy configured by default.
Procedure
Add the
evictionStrategy: LiveMigrate
option to thespec.template.spec
section in the virtual machine configuration file. This example usesoc edit
to update the relevant snippet of theVirtualMachine
configuration file:oc edit vm <custom-vm> -n <my-namespace>
$ oc edit vm <custom-vm> -n <my-namespace>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the virtual machine for the update to take effect:
virtctl restart <custom-vm> -n <my-namespace>
$ virtctl restart <custom-vm> -n <my-namespace>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow