Chapter 5. Migrating virtual machines from the command line interface
You can migrate virtual machines (VMs) to OpenShift Virtualization from the command line (CLI).
You must ensure that all prerequisites are met.
5.1. Migrating virtual machines Copy linkLink copied to clipboard!
You migrate virtual machines (VMs) from the command line (CLI) by creating MTV custom resources (CRs).
You must specify a name for cluster-scoped CRs.
You must specify both a name and a namespace for namespace-scoped CRs.
Prerequisites
-
You must be logged in as a user with
cluster-admin
privileges. - VMware only: You must have a VMware Virtual Disk Development Kit (VDDK) image in a secure registry that is accessible to all clusters.
Procedure
VMware only: Add the VDDK image to the
HyperConverged
CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the VDDK image that you created.
Create a
Secret
CR manifest for the source provider credentials:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the base64-encoded vCenter admin user or the RHV Manager user.
- 2
- Specify the base64-encoded password.
- 3
- RHV only: Specify the base64-encoded CA certificate of the Manager. You can retrieve it at
https://<www.example.com>/ovirt-engine/services/pki-resource?resource=ca-certificate&format=X509-PEM-CA
. - 4
- VMware only: Specify the vCenter SHA-1 fingerprint.
Create a
Provider
CR manifest for the source provider:Copy to Clipboard Copied! Toggle word wrap Toggle overflow VMware only: Create a
Host
CR manifest:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
NetworkMap
CR manifest to map the source and destination networks:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Allowed values are
pod
andmultus
. - 2
- You can use either the
id
or thename
parameter to specify the source network. - 3
- Specify the VMware network MOR or RHV network UUID.
- 4
- Specify a network attachment definition for each additional OpenShift Virtualization network.
- 5
- Specify the namespace of the OpenShift Virtualization network attachment definition.
Create a
StorageMap
CR manifest to map source and destination storage:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Create a
Hook
CR manifest to run custom code on a VM during the phase specified in thePlan
CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
Plan
CR manifest for the migration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the name of the
Plan
CR. - 2
- VMware only: Specify whether the migration is warm or cold. If you specify a warm migration without specifying a value for the
cutover
parameter in theMigration
CR manifest, only the precopy stage will run. Warm migration is not supported for RHV. - 3
- You can add multiple network mappings.
- 4
- Specify the name of the
NetworkMap
CR. - 5
- Specify the name of the
StorageMap
CR. - 6
- You can use either the
id
or thename
parameter to specify the source VMs. - 7
- Specify the VMware VM MOR or RHV VM UUID.
- 8
- Optional: You can specify up to two hooks for a VM. Each hook must run during a separate migration step.
- 9
- Specify the name of the
Hook
CR. - 10
- Allowed values are
PreHook
, before the migation plan starts, orPostHook
, after the migration is complete.
Optional, for VMware only: To change the time interval between the CBT snapshots for warm migration, patch the
vm-import-controller-config
config map:oc patch configmap/vm-import-controller-config \ -n openshift-cnv -p '{"data": \ {"warmImport.intervalMinutes": "<interval>"}}'
$ oc patch configmap/vm-import-controller-config \ -n openshift-cnv -p '{"data": \ {"warmImport.intervalMinutes": "<interval>"}}'
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the time interval in minutes. The default value is
60
.
Create a
Migration
CR manifest to run thePlan
CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the name of the
Migration
CR. - 2
- Specify the name of the
Plan
CR that you are running. TheMigration
CR creates aVirtualMachineImport
CR for each VM that is migrated. - 3
- Optional: Specify a cutover time according to the ISO 8601 format with the UTC time offset, for example,
2021-04-04T01:23:45.678+09:00
.
You can associate multiple
Migration
CRs with a singlePlan
CR. If a migration does not complete, you can create a newMigration
CR, without changing thePlan
CR, to migrate the remaining VMs.View the
VirtualMachineImport
pods to monitor the progress of the migration:oc get pods -n openshift-mtv
$ oc get pods -n openshift-mtv
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Canceling a migration Copy linkLink copied to clipboard!
You can cancel an entire migration or individual virtual machines (VMs) while a migration is in progress from the command line interface (CLI).
Canceling an entire migration
Delete the
Migration
CR:oc delete migration <migration> -n openshift-mtv
$ oc delete migration <migration> -n openshift-mtv
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Canceling the migration of individual VMs
Add the individual VMs to the
Migration
CR manifest:Copy to Clipboard Copied! Toggle word wrap Toggle overflow View the
VirtualMachineImport
pods to monitor the progress of the remaining VMs:oc get pods -n openshift-mtv
$ oc get pods -n openshift-mtv
Copy to Clipboard Copied! Toggle word wrap Toggle overflow