Live migrate a VM to another node in the cluster.
Outcomes
Observe and set the access mode for a storage profile.
Initiate a live migration through the web console and command line.
Monitor the progress of live migrations.
Cancel a live migration through the web console and command line.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
[student@workstation ~]$ lab start advanced-migrate
Instructions
As the admin user, confirm that the vm1 VM is running on the advanced-migrate project.
Open a command-line window and log in to the OpenShift cluster as the admin user with redhatocp as the password.
[student@workstation ~]$oc login -u admin -p redhatocp \https://api.ocp4.example.com:6443Login Successful ...output omitted...
Identify the URL for the OpenShift web console.
[student@workstation ~]$ oc whoami --show-console
https://console-openshift-console.apps.ocp4.example.comOpen a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com.
Click and log in as the admin user with redhatocp as the password.
Navigate to → .
Select the advanced-migrate project from the list.
Confirm that the vm1 VM is running.
Confirm that the vm1 VM is not migratable.
Determine the storage class of the VM's empty tempdata disk.
Click the vertical ellipsis icon at the right of the vm1 VM and then confirm that is disabled.
![]() |
The and columns show the and values for the vm1 VM.
![]() |
The live migration is not available because the empty tempdata PersistentVolumeClaim (PVC) is not configured with a ReadWriteMany access mode.
Identify the storage class for the tempdata disk.
Select the vm1 VM.
Navigate to the tab.
In the section, notice that the tempdata disk uses the nfs-storage storage class.
Retrieve the current default storage class settings for Red Hat OpenShift Virtualization.
Configure the nfs-storage storage class to use ReadWriteMany access mode.
From a command-line, execute the oc describe command to retrieve the nfs-storage storage profile.
Notice that the nfs-storage storage class defaults to a ReadWriteOnce access mode.
[student@workstation ~]$oc describe storageprofile nfs-storage...output omitted... Spec: Claim Property Sets: Access Modes:ReadWriteOnceVolume Mode: Filesystem ...output omitted...
Change the nfs-storage access mode to ReadWriteMany by using the oc edit command.
You can copy and then paste the command from the ~/DO316/labs/advanced-migrate/commands.txt file.
[student@workstation ~]$oc edit storageprofile nfs-storage...output omitted... spec: claimPropertySets: - accessModes: -ReadWriteManyvolumeMode: FileSystem ...output omitted...
Confirm that the nfs-storage storage profile is updated with the correct access mode.
[student@workstation ~]$oc describe storageprofile nfs-storage...output omitted... Spec: Claim Property Sets: Access Modes:ReadWriteManyVolume Mode: Filesystem ...output omitted...
Delete the empty tempdata disk from the vm1 VM.
Attach a new 2 GiB blank disk named newtempdata that uses the nfs-storage storage class.
You must stop the vm1 VM before you can modify the VM's disks.
In the OpenShift web console, navigate to → .
Select the vm1 VM and then click → .
Wait for the VM to stop.
Navigate to the tab.
In the section, click the vertical ellipsis icon at the right of the tempdata disk and then click .
Click to confirm the operation.
Click to create a disk.
Select as the source and then enter newtempdata for the name.
Set the field to 2 GiB value and leave the virtio value for the field.
Confirm that the field is set to the value, and that the field is set to the value.
Clear and click to add the disk.
Click → to power on the VM. Wait a few moments for the operation to complete.
Live migrate the vm1 VM in the OpenShift web console.
Afterwards, initiate and then cancel another live migration for the VM.
In the web console, navigate to → .
The column shows the compute node for the vm1 VM.
Make note of the compute node that is hosting the VM.
Click the vertical ellipsis icon at the right of the vm1 VM and then click .
Wait a few moments for the migration to complete.
Confirm that the column shows a different compute node for the vm1 VM than identified in an earlier step.
Initiate another live migration for the VM.
Click the vertical ellipsis icon at the right of the vm1 VM and then click .
Cancel the live migration.
Click the vertical ellipsis icon at the right of the vm1 VM and then click .
Initiate another live migration for the vm1 VM by using a VirtualMachineInstanceMigration manifest.
In a text editor, modify the migrate-vmi.yml file in the ~/DO316/labs/advanced-migrate/ directory.
apiVersion: kubevirt.io/v1 kind: VirtualMachineInstanceMigration metadata: name:vm1-migration-jobspec: vmiName:vm1
In the terminal, use the oc create command to initiate the live migration with the migrate-vmi.yml manifest.
[student@workstation ~]$oc create -f \~/DO316/labs/advanced-migrate/migrate-vmi.yml -n advanced-migratevirtualmachineinstancemigration.kubevirt.io/vm1-migration-job created
Monitor the live migration with the oc describe vmi command.
Confirm that vm1 is migrated to another node and make note of the node's name.
You might have to wait a few minutes and rerun the command several times.
[student@workstation ~]$oc describe vmi vm1 -n advanced-migrate...output omitted... Events: Type Reason Age From Message ---- ------ ---- ---- ------- ...output omitted... Normal SuccessfulUpdate 119s virtualmachine-controller Expanded PodDisruptionBudget kubevirt-disruption-budget-8dg2q Normal Migrating 84s (x2 over 7m23s) virt-handler VirtualMachineInstance is migrating. Normal PreparingTarget 84s (x4 over 7m23s) virt-handler VirtualMachineInstance Migration Target Prepared. Normal PreparingTarget 84s virt-handler Migration Target is listening at 10.8.2.35, on ports: 39015,38699,40715Normal Migrated 81s virt-handler The VirtualMachineInstance migrated to node worker02.Normal Deleted 81s virt-handler Signaled Deletion Normal SuccessfulUpdate 77s disruptionbudget-controller shrank PodDisruptionBudget kubevirt-disruption-budget-8dg2q
Use the command line to initiate and then cancel a live migration for the vm1 VM.
In your terminal, delete the previous vm1-migration-job with the oc delete vmim command.
[student@workstation ~]$ oc delete vmim vm1-migration-job -n advanced-migrate
virtualmachineinstancemigration.kubevirt.io "vm1-migration-job" deletedUse the oc create command to initiate a live migration with the migrate-vmi.yml file.
[student@workstation ~]$oc create \-f ~/DO316/labs/advanced-migrate/migrate-vmi.yml -n advanced-migratevirtualmachineinstancemigration.kubevirt.io/vm1-migration-job created
Cancel the live migration by deleting the VirtualMachineInstanceMigration object.
[student@workstation ~]$ oc delete vmim vm1-migration-job -n advanced-migrate
virtualmachineinstancemigration.kubevirt.io "vm1-migration-job" deletedConfirm that the VM is not migrated to another node.
[student@workstation ~]$oc describe vmi vm1 -n advanced-migrate...output omitted... Events: Type Reason Age From Message ---- ------ ---- ---- ------- ...output omitted... Normal Migrating 10s virt-handler VirtualMachineInstance is migrating. Normal PreparingTarget 10s virt-handler VirtualMachineInstance Migration Target Prepared. Normal PreparingTarget 10s virt-handler Migration Target is listening at 10.8.2.7, on ports: 43169,35525,40499Normal Migrating 10s virt-handler VirtualMachineInstance is aborting migration....output omitted...
Close the web browser.