Chapter 8. Migrating from OpenShift Virtualization
Run your OpenShift Virtualization migration plan from the MTV UI or from the command-line.
8.1. Prerequisites Copy linkLink copied to clipboard!
- You have planned your migration from OpenShift Virtualization.
8.2. Running a migration plan in the MTV UI Copy linkLink copied to clipboard!
You can run a migration plan and view its progress in the Red Hat OpenShift web console.
Prerequisites
- Valid migration plan.
Procedure
In the Red Hat OpenShift web console, click Migration for Virtualization > Migration plans.
The Plans list displays the source and target providers, the number of virtual machines (VMs) being migrated, the status, the date that the migration started, and the description of each plan.
- Click Start beside a migration plan to start the migration.
Click Start in the confirmation window that opens.
The plan’s Status changes to Running, and the migration’s progress is displayed.
WarningDo not take a snapshot of a VM after you start a migration. Taking a snapshot after a migration starts might cause the migration to fail.
Optional: Click the links in the migration’s Status to see its overall status and the status of each VM:
- The link on the left indicates whether the migration failed, succeeded, or is ongoing. It also reports the number of VMs whose migration succeeded, failed, or was canceled.
The link on the right opens the Virtual machines tab of the Plan details page. For each VM, the tab displays the following data:
- The name of the VM
- The start and end times of the migration
- The amount of data copied
- A progress pipeline for the VM’s migration
To view your migration’s logs, either as it is running or after it is completed:
- Click the Virtual machines tab.
- Click the arrow (>) before the name of the virtual machine whose migration progress you want to check.
In the Pods section, in the Pod links column, click the Logs link.
The Logs tab opens.
NoteLogs might not be available for the following common reasons:
-
The migration is from OpenShift Virtualization to OpenShift Virtualization. In this case, the
virt-v2vutility is not involved, so no pod is required. - No pod was created.
- The pod was deleted.
- The migration failed before running the pod.
-
The migration is from OpenShift Virtualization to OpenShift Virtualization. In this case, the
- To see the raw logs, click the Raw link.
- To download the logs, click the Download link.
8.2.1. Migration plan options Copy linkLink copied to clipboard!
On the Migration plans page of the Red Hat OpenShift web console, you can click the Options menu
beside a migration plan to access the following options:
Edit Plan: Edit the details of a migration plan. If the plan is running or has completed successfully, you cannot edit the following options:
- All properties on the Settings section of the Plan details page. For example, warm or cold migration, target namespace, and preserved static IPs.
- The plan’s mapping on the Mappings tab.
- The hooks listed on the Hooks tab.
- Start migration
- Restart migration: Restart a migration that was interrupted. Before choosing this option, make sure there are no error messages. If there are, you need to edit the plan.
Duplicate: Create a new migration plan with the same virtual machines (VMs), parameters, mappings, and hooks as an existing plan. You can use this feature for the following tasks:
- Migrate VMs to a different namespace.
- Edit an archived migration plan.
- Edit a migration plan with a different status, for example, failed, canceled, running, critical, or ready.
Archive: Delete the logs, history, and metadata of a migration plan. The plan cannot be edited or restarted. It can only be viewed, duplicated, or deleted.
NoteArchive is irreversible. However, you can duplicate an archived plan.
Delete: Permanently remove a migration plan. You cannot delete a running migration plan.
NoteDelete is irreversible.
Deleting a migration plan does not remove temporary resources. To remove temporary resources, archive the plan first before deleting it.
NoteThe results of archiving and then deleting a migration plan vary by whether you created the plan and its storage and network mappings using the CLI or the UI.
- If you created them using the UI, then the migration plan and its mappings no longer appear in the UI.
- If you created them using the CLI, then the mappings might still appear in the UI. This is because mappings in the CLI can be used by more than one migration plan, but mappings created in the UI can only be used in one migration plan.
8.2.2. Canceling a migration Copy linkLink copied to clipboard!
You can cancel the migration of some or all virtual machines (VMs) while a migration plan is in progress by using the Red Hat OpenShift web console.
Procedure
- In the Red Hat OpenShift web console, click Migration for Virtualization > Migration plans.
- Click the name of a running migration plan to view the migration details.
- Select one or more VMs and click Cancel.
Click Yes, cancel to confirm the cancellation.
In the Migration details by VM list, the status of the canceled VMs is Canceled. The unmigrated and the migrated virtual machines are not affected.
- Restart a canceled migration by clicking Restart beside the migration plan on the Migration plans page.
8.3. Running a Red Hat OpenShift Virtualization migration from the command-line Copy linkLink copied to clipboard!
You can use a Red Hat OpenShift Virtualization provider as either a source provider or as a destination provider. You can migrate from an OpenShift Virtualization source provider by using the command-line interface (CLI).
The Red Hat OpenShift cluster version of the source provider must be 4.16 or later.
Procedure
Create a
Secretmanifest for the source provider credentials:$ cat << EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: <secret> namespace: <namespace> ownerReferences: - apiVersion: forklift.konveyor.io/v1beta1 kind: Provider name: <provider_name> uid: <provider_uid> labels: createdForProviderType: openshift createdForResourceType: providers type: Opaque stringData: token: <token> password: <password> insecureSkipVerify: <"true"/"false"> cacert: | <ca_certificate> url: <api_end_point> EOFwhere:
<namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. ownerReferences-
Is an optional section in which you can specify a provider’s
nameanduid. <token>-
Specifies a token for a service account with
cluster-adminprivileges. If bothtokenandurlare left blank, the local OpenShift cluster is used. <password>- Specifies the user password.
<"true"/"false">-
Specifies
"true"to skip certificate verification, and specifies"false"to verify the certificate. Defaults to"false"if not specified. Skipping certificate verification proceeds with an insecure migration and then the certificate is not required. Insecure migration means that the transferred data is sent over an insecure connection and potentially sensitive data could be exposed. cacert- Specifies the CA cert object. When this field is not set and skip certificate verification is disabled, MTV attempts to use the system CA.
<api_end_point>- Specifies the URL of the endpoint of the API server.
Create a
Providermanifest for the source provider:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Provider metadata: name: <source_provider> namespace: <namespace> spec: type: openshift url: <api_end_point> secret: name: <secret> namespace: <namespace> EOFwhere:
<namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. <api_end_point>- Specifies the URL of the endpoint of the API server.
<secret>-
Specifies the name of the provider
SecretCR.
Create a
NetworkMapmanifest to map the source and destination networks:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: NetworkMap metadata: name: <network_map> namespace: <namespace> spec: map: - destination: name: <network_name> type: pod source: name: <network_name> type: pod - destination: name: <network_attachment_definition> namespace: <network_attachment_definition_namespace> type: multus source: name: <network_attachment_definition> namespace: <network_attachment_definition_namespace> type: multus provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> EOFwhere:
<namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. type-
Specifies the network type. Allowed values are
pod,ignored, andmultus. <network_attachment_definition>-
Specifies the network name. When the
typeismultus, use the OpenShift Virtualization (NAD) name. <network_attachment_definition_namespace>-
Specifies the namespace of the OpenShift Virtualization NAD. Required only when the
typeismultus.
Create a
StorageMapmanifest to map source and destination storage:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: <storage_map> namespace: <namespace> spec: map: - destination: storageClass: <storage_class> accessMode: <access_mode> source: name: <storage_class> provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> EOFwhere:
<namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. <access_mode>-
Specifies the access mode. Allowed values are
ReadWriteOnceandReadWriteMany.
Optional: Create a
Hookmanifest to run custom code on a VM during the phase specified in thePlanCR:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Hook metadata: name: <hook> namespace: <namespace> spec: image: registry.redhat.io/rhmtc/openshift-migration-hook-runner-rhel8 serviceAccount:<service account> playbook: | LS0tCi0gbm... EOFwhere:
<namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. <service account>-
Specifies the Red Hat OpenShift service account. This is an optional field. Use the
serviceAccountparameter to modify any cluster resources. playbookSpecifies the Base64-encoded Ansible Playbook. If you specify a playbook, the
imagemust include anansible-runner.NoteYou can use the default
hook-runnerimage or specify a custom image. If you specify a custom image, you do not have to specify a playbook.
Enter the following command to create the network attachment definition (NAD) of the transfer network used for MTV migrations.
You use this definition to configure an IP address for the interface, either from the Dynamic Host Configuration Protocol (DHCP) or statically.
Configuring the IP address enables the interface to reach the configured gateway.
$ oc edit NetworkAttachmentDefinitions <name_of_the_NAD_to_edit> apiVersion: k8s.cni.cncf.io/v1 kind: NetworkAttachmentDefinition metadata: name: <name_of_transfer_network> namespace: <namespace> annotations: forklift.konveyor.io/route: <IP_address>Create a
Planmanifest for the migration:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Plan metadata: name: <plan> namespace: <namespace> spec: provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> map: network: name: <network_map> namespace: <namespace> storage: name: <storage_map> namespace: <namespace> targetNamespace: <target_namespace> pvcNameTemplate: <pvc_name_template> vms: - name: <source_vm> namespace: <namespace> pvcNameTemplate: <pvc_name_template_for_this_vm> hooks: - hook: namespace: <namespace> name: <hook> step: <step> EOFwhere:
<plan>-
Specifies the name of the
PlanCR. <namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. map- Specifies the network map and storage map used by the plan.
<source_provider>-
Specifies the name of the source
ProviderCR. <destination_provider>-
Specifies the name of the destination
ProviderCR. <network_map>-
Specifies the name of the
NetworkMapCR. <storage_map>-
Specifies the name of the
StorageMapCR. <target_namespace>- Specifies the target namespace in the destination cluster.
<pvc_name_template>- Specifies a template for the persistent volume claim (PVC) name for all VMs in the plan. This is an optional field. For a list of available variables, template functions, and examples, see PVC name template variables for OpenShift Virtualization-to-OpenShift Virtualization migrations.
<source_vm>- Specifies the name of the source VM to migrate.
<pvc_name_template_for_this_vm>- Specifies a template for the PVC name for this specific VM, overriding the plan-level template. This is an optional field.
hooks- Specifies up to two hooks for a VM. Each hook must run during a separate migration step. This is an optional field.
<hook>-
Specifies the name of the
HookCR. <step>-
Specifies the type of hook. Allowed values are
PreHook, before the migration plan starts, orPostHook, after the migration is complete.
Create a
Migrationmanifest to run thePlanCR:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: <name_of_migration_cr> namespace: <namespace> spec: plan: name: <name_of_plan_cr> namespace: <namespace> cutover: <optional_cutover_time> EOFNoteIf you specify a cutover time, use the ISO 8601 format with the UTC time offset, for example,
2024-04-04T01:23:45.678+09:00.
8.4. Running a Red Hat OpenShift Virtualization live migration from the command-line Copy linkLink copied to clipboard!
You can perform a live migration by using the command-line interface (CLI). The procedure for live migration is identical to the procedure for other migrations between OpenShift Virtualization clusters except for the addition of the type label in the Plan CR. For a live migration, the type label must be set to live.
Prerequisites
Ensure you meet the OpenShift Virtualization live migration prerequisites. For more information, see OpenShift Virtualization live migration prerequisites.
Procedure
Create a
Secretmanifest for the source provider credentials:$ cat << EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: <secret> namespace: <namespace> ownerReferences: - apiVersion: forklift.konveyor.io/v1beta1 kind: Provider name: <provider_name> uid: <provider_uid> labels: createdForProviderType: openshift createdForResourceType: providers type: Opaque stringData: token: <token> password: <password> insecureSkipVerify: <"true"/"false"> cacert: | <ca_certificate> url: <api_end_point> EOFwhere:
ownerReferences-
Is an optional section in which you can specify a provider’s
nameanduid. <token>-
Specifies a token for a service account with
cluster-adminprivileges. If bothtokenandurlare left blank, the local OpenShift cluster is used. <password>- Specifies the user password.
<"true"/"false">-
Specifies
"true"to skip certificate verification, and specifies"false"to verify the certificate. Defaults to"false"if not specified. Skipping certificate verification proceeds with an insecure migration and then the certificate is not required. Insecure migration means that the transferred data is sent over an insecure connection and potentially sensitive data could be exposed. cacert- Specifies the CA cert object. When this field is not set and skip certificate verification is disabled, MTV attempts to use the system CA.
<api_end_point>- Specifies the URL of the endpoint of the API server.
Create a
Providermanifest for the source provider:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Provider metadata: name: <source_provider> namespace: <namespace> spec: type: openshift url: <api_end_point> secret: name: <secret> namespace: <namespace> EOFwhere:
<api_end_point>- Specifies the URL of the endpoint of the API server.
<secret>-
Specifies the name of the provider
SecretCR.
Create a
NetworkMapmanifest to map the source and destination networks:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: NetworkMap metadata: name: <network_map> namespace: <namespace> spec: map: - destination: name: <network_name> type: pod source: name: <network_name> type: pod - destination: name: <network_attachment_definition> namespace: <network_attachment_definition_namespace> type: multus source: name: <network_attachment_definition> namespace: <network_attachment_definition_namespace> type: multus provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> EOFwhere:
type-
Specifies the network type. Allowed values are
pod,ignored, andmultus. <network_attachment_definition>-
Specifies the network name. When the
typeismultus, use the name of the OpenShift Virtualization network attachment (NAD) definition. <network_attachment_definition_namespace>-
Specifies the namespace of the OpenShift Virtualization NAD. Required only when the
typeismultus.
Create a
StorageMapmanifest to map source and destination storage:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: <storage_map> namespace: <namespace> spec: map: - destination: storageClass: <storage_class> accessMode: <access_mode> source: name: <storage_class> provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> EOFwhere:
<access_mode>-
Specifies the access mode. Allowed values are
ReadWriteOnceandReadWriteMany.
Optional: Create a
Hookmanifest to run custom code on a VM during the phase specified in thePlanCR:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Hook metadata: name: <hook> namespace: <namespace> spec: image: registry.redhat.io/rhmtc/openshift-migration-hook-runner-rhel8 serviceAccount: <service_account> playbook: | LS0tCi0gbm... EOFwhere:
serviceAccount-
Specifies the Red Hat OpenShift service account. This is an optional label. Use the
serviceAccountparameter to modify any cluster resources. playbookSpecifies the Base64-encoded Ansible Playbook. If you specify a playbook, the
imagemust include anansible-runner.NoteYou can use the default
hook-runnerimage or specify a custom image. If you specify a custom image, you do not have to specify a playbook.
Create a
Planmanifest for the migration:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Plan metadata: name: <plan> namespace: <namespace> spec: provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> map: network: name: <network_map> namespace: <namespace> storage: name: <storage_map> namespace: <namespace> type: live targetNamespace: <target_namespace> pvcNameTemplate: <pvc_name_template> vms: - name: <source_vm> namespace: <namespace> pvcNameTemplate: <pvc_name_template_for_this_vm> hooks: - hook: namespace: <namespace> name: <hook> step: <step> EOFwhere:
<plan>-
Specifies the name of the
PlanCR. <namespace>-
Specifies the namespace for the resource. Use
openshift-mtvfor the MTV namespace, or specify a custom namespace if you have configured providers in a different project. <source_provider>-
Specifies the name of the source
ProviderCR. <destination_provider>-
Specifies the name of the destination
ProviderCR. <network_map>-
Specifies the name of the
NetworkMapCR. <storage_map>-
Specifies the name of the
StorageMapCR. type-
Specifies the type of migration. Must be set to
live. <target_namespace>- Specifies the target namespace in the destination cluster.
<pvc_name_template>- Specifies a template for the persistent volume claim (PVC) name for all VMs in the plan. This is an optional field. For a list of available variables, template functions, and examples, see PVC name template variables for OpenShift Virtualization-to-OpenShift Virtualization migrations.
<source_vm>- Specifies the name of the source VM to migrate.
<pvc_name_template_for_this_vm>- Specifies a template for the PVC name for this specific VM, overriding the plan-level template. This is an optional field.
<hook>-
Specifies the name of the
HookCR. <step>-
Specifies the hook step. Allowed values are
PreHook, before the migration plan starts, orPostHook, after the migration is complete.
Create a
Migrationmanifest to run thePlanCR:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: <name_of_migration_cr> namespace: <namespace> spec: plan: name: <name_of_plan_cr> namespace: <namespace> EOFNoteThe
cutoverfield is irrelevant for live migrations, so it is not included in theMigrationCR of this procedure.
8.4.1. Canceling a migration from the command-line interface Copy linkLink copied to clipboard!
You can use the command-line interface (CLI) to cancel either an entire migration or the migration of specific virtual machines (VMs) while a migration is in progress.
8.4.1.1. Canceling an entire migration from the command-line interface Copy linkLink copied to clipboard!
You can use the command-line interface (CLI) to cancel an entire migration while a migration is in progress.
Procedure
Delete the
MigrationCR:$ oc delete migration <migration> -n <namespace>where:
<migration>-
Specifies the name of the
MigrationCR.
8.4.1.2. Canceling the migration of specific VMs from the command-line interface Copy linkLink copied to clipboard!
You can use the command-line interface (CLI) to cancel the migration of specific virtual machines (VMs) while a migration is in progress.
Procedure
Add the specific VMs to the
spec.cancelblock of theMigrationmanifest, following this example:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: <migration> namespace: <namespace> ... spec: cancel: - id: vm-102 - id: vm-203 name: rhel8-vm EOFwhere:
idornameSpecifies a VM by using the
idkey or thenamekey.The value of the
idkey is the VM name for a OpenShift Virtualization VM.
Retrieve the
Migrationcustom resource (CR) to monitor the progress of the remaining VMs, following this example:$ oc get migration/<migration> -n <namespace> -o yaml