Questo contenuto non è disponibile nella lingua selezionata.
Chapter 11. Live migration
11.1. Virtual machine live migration Copia collegamentoCollegamento copiato negli appunti!
11.1.1. About live migration Copia collegamentoCollegamento copiato negli appunti!
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
You can use live migration if the following conditions are met:
-
Shared storage with (RWX) access mode.
ReadWriteMany - Sufficient RAM and network bandwidth.
- If the virtual machine uses a host model CPU, the nodes must support the virtual machine’s host model CPU.
By default, live migration traffic is encrypted using Transport Layer Security (TLS).
11.2. Live migration limits and timeouts Copia collegamentoCollegamento copiato negli appunti!
Apply live migration limits and timeouts so that migration processes do not overwhelm the cluster. Configure these settings by editing the
HyperConverged
11.2.1. Configuring live migration limits and timeouts Copia collegamentoCollegamento copiato negli appunti!
Configure live migration limits and timeouts for the cluster by updating the
HyperConverged
openshift-cnv
Procedure
Edit the
CR and add the necessary live migration parameters.HyperConverged$ oc edit hco -n openshift-cnv kubevirt-hyperconvergedExample configuration file
apiVersion: hco.kubevirt.io/v1beta1 kind: HyperConverged metadata: name: kubevirt-hyperconverged namespace: openshift-cnv spec: liveMigrationConfig:1 bandwidthPerMigration: 64Mi completionTimeoutPerGiB: 800 parallelMigrationsPerCluster: 5 parallelOutboundMigrationsPerNode: 2 progressTimeout: 150- 1
- In this example, the
spec.liveMigrationConfigarray contains the default values for each field.
NoteYou can restore the default value for any
field by deleting that key/value pair and saving the file. For example, deletespec.liveMigrationConfigto restore the defaultprogressTimeout: <value>.progressTimeout: 150
11.2.2. Cluster-wide live migration limits and timeouts Copia collegamentoCollegamento copiato negli appunti!
| 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, where the value is the quantity of bytes per second. For example, a value of
| 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 is unlimited.
0
11.3. Migrating a virtual machine instance to another node Copia collegamentoCollegamento copiato negli appunti!
Manually initiate a live migration of a virtual machine instance to another node using either the web console or the CLI.
If a virtual machine uses a host model CPU, you can perform live migration of that virtual machine only between nodes that support its host CPU model.
11.3.1. Initiating live migration of a virtual machine instance in the web console Copia collegamentoCollegamento copiato negli appunti!
Migrate a running virtual machine instance to a different node in the cluster.
The Migrate action is visible to all users but only admin users can initiate a virtual machine migration.
Procedure
-
In the OpenShift Container Platform console, click Virtualization
VirtualMachines from the side menu. You can initiate the migration from this page, which makes it easier to perform actions on multiple virtual machines on the same page, or from the VirtualMachine details page where you can view comprehensive details of the selected virtual machine:
-
Click the Options menu
next to the virtual machine and select Migrate.
-
Click the virtual machine name to open the VirtualMachine details page and click Actions
Migrate.
-
Click the Options menu
- Click Migrate to migrate the virtual machine to another node.
11.3.2. Initiating live migration of a virtual machine instance in the CLI Copia collegamentoCollegamento copiato negli appunti!
Initiate a live migration of a running virtual machine instance by creating a
VirtualMachineInstanceMigration
Procedure
Create a
configuration file for the virtual machine instance to migrate. For example,VirtualMachineInstanceMigration:vmi-migrate.yamlapiVersion: kubevirt.io/v1 kind: VirtualMachineInstanceMigration metadata: name: migration-job spec: vmiName: vmi-fedoraCreate the object in the cluster by running the following command:
$ oc create -f vmi-migrate.yaml
The
VirtualMachineInstanceMigration
11.4. Migrating a virtual machine over a dedicated additional network Copia collegamentoCollegamento copiato negli appunti!
You can configure a dedicated Multus network for live migration. A dedicated network minimizes the effects of network saturation on tenant workloads during live migration.
11.4.1. Configuring a dedicated secondary network for virtual machine live migration Copia collegamentoCollegamento copiato negli appunti!
To configure a dedicated secondary network for live migration, you must first create a bridge network attachment definition for the
openshift-cnv
NetworkAttachmentDefinition
HyperConverged
Prerequisites
-
You installed the OpenShift CLI ().
oc -
You logged in to the cluster as a user with the role.
cluster-admin - The Multus Container Network Interface (CNI) plugin is installed on the cluster.
- Every node on the cluster has at least two Network Interface Cards (NICs), and the NICs to be used for live migration are connected to the same VLAN.
-
The virtual machine (VM) is running with the eviction strategy.
LiveMigrate
Procedure
Create a
manifest.NetworkAttachmentDefinitionExample configuration file
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: my-secondary-network1 namespace: openshift-cnv2 spec: config: '{ "cniVersion": "0.3.1", "name": "migration-bridge", "type": "macvlan", "master": "eth1",3 "mode": "bridge", "ipam": { "type": "whereabouts",4 "range": "10.200.5.0/24"5 } }'- 1
- The name of the
NetworkAttachmentDefinitionobject. - 2
- The namespace where the
NetworkAttachmentDefinitionobject resides. This must beopenshift-cnv. - 3
- The name of the NIC to be used for live migration.
- 4
- The name of the CNI plugin that provides the network for this network attachment definition.
- 5
- The IP address range for the secondary network. This range must not have any overlap with the IP addresses of the main network.
Open the
CR in your default editor by running the following command:HyperConvergedoc edit hyperconverged kubevirt-hyperconverged -n openshift-cnvAdd the name of the
object to theNetworkAttachmentDefinitionstanza of thespec.liveMigrationConfigCR. For example:HyperConvergedExample configuration file
apiVersion: hco.kubevirt.io/v1beta1 kind: HyperConverged metadata: name: kubevirt-hyperconverged spec: liveMigrationConfig: completionTimeoutPerGiB: 800 network: my-secondary-network1 parallelMigrationsPerCluster: 5 parallelOutboundMigrationsPerNode: 2 progressTimeout: 150 ...- 1
- The name of the Multus
NetworkAttachmentDefinitionobject to be used for live migrations.
-
Save your changes and exit the editor. The pods restart and connect to the secondary network.
virt-handler
Verification
When the node that the virtual machine runs on is placed into maintenance mode, the VM automatically migrates to another node in the cluster. You can verify that the migration occurred over the secondary network and not the default pod network by checking the target IP address in the virtual machine instance (VMI) metadata.
oc get vmi <vmi_name> -o jsonpath='{.status.migrationState.targetNodeAddress}'
11.4.2. Additional resources Copia collegamentoCollegamento copiato negli appunti!
11.5. Monitoring live migration of a virtual machine instance Copia collegamentoCollegamento copiato negli appunti!
You can monitor the progress of a live migration of a virtual machine instance from either the web console or the CLI.
11.5.1. Monitoring live migration of a virtual machine instance in the web console Copia collegamentoCollegamento copiato negli appunti!
For the duration of the migration, the virtual machine has a status of Migrating. This status is displayed on the VirtualMachines page or on the VirtualMachine details page of the migrating virtual machine.
Procedure
-
In the OpenShift Container Platform console, click Virtualization
VirtualMachines from the side menu. - Select a virtual machine to open the VirtualMachine details page.
11.5.2. Monitoring live migration of a virtual machine instance in the CLI Copia collegamentoCollegamento copiato negli appunti!
The status of the virtual machine migration is stored in the
Status
VirtualMachineInstance
Procedure
Use the
command on the migrating virtual machine instance:oc describe$ oc describe vmi vmi-fedoraExample output
... Status: Conditions: Last Probe Time: <nil> Last Transition Time: <nil> Status: True Type: LiveMigratable Migration Method: LiveMigration Migration State: Completed: true End Timestamp: 2018-12-24T06:19:42Z Migration UID: d78c8962-0743-11e9-a540-fa163e0c69f1 Source Node: node2.example.com Start Timestamp: 2018-12-24T06:19:35Z Target Node: node1.example.com Target Node Address: 10.9.0.18:43891 Target Node Domain Detected: true
11.6. Cancelling the live migration of a virtual machine instance Copia collegamentoCollegamento copiato negli appunti!
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.
11.6.1. Cancelling live migration of a virtual machine instance in the web console Copia collegamentoCollegamento copiato negli appunti!
You can cancel the live migration of a virtual machine instance in the web console.
Procedure
-
In the OpenShift Container Platform console, click Virtualization
VirtualMachines from the side menu. -
Click the Options menu
beside a virtual machine and select Cancel Migration.
11.6.2. Cancelling live migration of a virtual machine instance in the CLI Copia collegamentoCollegamento copiato negli appunti!
Cancel the live migration of a virtual machine instance by deleting the
VirtualMachineInstanceMigration
Procedure
Delete the
object that triggered the live migration,VirtualMachineInstanceMigrationin this example:migration-job$ oc delete vmim migration-job
11.7. Configuring virtual machine eviction strategy Copia collegamentoCollegamento copiato negli appunti!
The
LiveMigrate
11.7.1. Configuring custom virtual machines with the LiveMigration eviction strategy Copia collegamentoCollegamento copiato negli appunti!
You only need to configure the
LiveMigration
Procedure
Add the
option to theevictionStrategy: LiveMigratesection in the virtual machine configuration file. This example usesspec.template.specto update the relevant snippet of theoc editconfiguration file:VirtualMachine$ oc edit vm <custom-vm> -n <my-namespace>apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: custom-vm spec: template: spec: evictionStrategy: LiveMigrate ...Restart the virtual machine for the update to take effect:
$ virtctl restart <custom-vm> -n <my-namespace>
11.8. Configuring live migration policies Copia collegamentoCollegamento copiato negli appunti!
You can define different migration configurations for specified groups of virtual machine instances (VMIs) by using a live migration policy.
Live migration policy is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
11.8.1. Configuring a live migration policy Copia collegamentoCollegamento copiato negli appunti!
Use the
MigrationPolicy
You can specify groups of VMIs by using any combination of the following:
-
Virtual machine instance labels such as ,
size,os, and other VMI labels.gpu -
Namespace labels such as ,
priority,bandwidth, and other namespace labels.hpc-workload
For the policy to apply to a specific group of VMIs, all labels on the group of VMIs must match the labels in the policy.
If multiple live migration policies apply to a VMI, the policy with the highest number of matching labels takes precedence. If multiple policies meet this criteria, the policies are sorted by lexicographic order of the matching labels keys, and the first one in that order takes precedence.
Procedure
Create a
CRD for your specified group of VMIs. The following example YAML configures a group with the labelsMigrationPolicy,hpc-workloads:true,xyz-workloads-type: "", andworkload-type: db:operating-system: ""apiVersion: migrations.kubevirt.io/v1alpha1 kind: MigrationPolicy metadata: name: my-awesome-policy spec: # Migration Configuration allowAutoConverge: true bandwidthPerMigration: 217Ki completionTimeoutPerGiB: 23 allowPostCopy: false # Matching to VMIs selectors: namespaceSelector:1 matchLabels: hpc-workloads: "True" xyz-workloads-type: "" virtualMachineInstanceSelector:2 matchLabels: workload-type: "db" operating-system: ""