Chapter 7. Migrating from AWS EC2
Run your AWS EC2 migration plan from the MTV UI or from the command-line.
7.1. Prerequisites Copy linkLink copied to clipboard!
- You have planned your migration from AWS EC2.
7.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.
7.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.
7.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.
7.3. Running an EC2 migration from the command-line Copy linkLink copied to clipboard!
You can migrate EC2 instances to OpenShift Virtualization by using the command-line interface (CLI) to create and configure Secret, Provider, NetworkMap, StorageMap, Plan, and Migration custom resources.
Prerequisites
- OpenShift Virtualization destination provider configured
- EC2 instances must be stopped before migration
Procedure
Create a
Secretmanifest for the source provider credentials:$ cat << EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: <secret> namespace: <namespace> type: Opaque stringData: region: <aws_region> accessKeyId: <aws_access_key_id> secretAccessKey: <aws_secret_access_key> # targetAccessKeyId: <target_aws_access_key_id> # targetSecretAccessKey: <target_aws_secret_access_key> EOFwhere:
<secret>-
Specifies the name of the
SecretCR. <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. <aws_region>-
Specifies the region where your EC2 instances are located, for example,
us-east-1orus-east-2. <aws_access_key_id>- Specifies the access key ID for the source account.
<aws_secret_access_key>- Specifies the secret access key for the source account.
<target_aws_access_key_id>- Specifies the access key ID for the target account. Required only for cross-account migrations.
<target_aws_secret_access_key>Specifies the secret access key for the target account. Required only for cross-account migrations.
NoteFor same-account migrations, use the OpenShift cluster’s credentials to ensure the Elastic Block Store (EBS) Container Storage Interface (CSI) driver can access the migrated volumes.
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: ec2 secret: name: <secret> namespace: <namespace> settings: target-az: <target_availability_zone> 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. <source_provider>- Specifies the name of the source provider.
<secret>-
Specifies the name of the provider
SecretCR. <target_availability_zone>Specifies the target availability zone where MTV creates EBS volumes, for example,
us-east-1a. This must match an availability zone where OpenShift worker nodes run.ImportantEBS volumes are availability zone-specific. If the
target-azsetting does not match an availability zone where OpenShift worker nodes run, the EBS CSI driver cannot attach the volumes to worker nodes, causing the migration to fail.
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: id: <source_subnet_id> - destination: name: <network_attachment_definition> namespace: <network_attachment_definition_namespace> type: multus source: id: <source_subnet_id> provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> EOFwhere:
<network_map>- Specifies the name of the network map.
<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_subnet_id>-
Specifies the subnet ID (for example,
subnet-abc123def456). type-
Specifies the network type. Allowed values are
podandmultus. <network_attachment_definition>- Specifies a network attachment definition (NAD) for each additional OpenShift Virtualization network.
<network_attachment_definition_namespace>-
Specifies the namespace of the OpenShift Virtualization NAD. Required only when
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> source: id: <source_volume_type> provider: source: name: <source_provider> namespace: <namespace> destination: name: <destination_provider> namespace: <namespace> EOFwhere:
<storage_map>- Specifies the name of the storage map.
<storage_class>-
Specifies the storage class that uses the EBS CSI driver. The storage class must be configured for the same availability zone as the
target-azsetting in the Provider resource. <source_volume_type>-
Specifies the EBS volume type (for example,
gp2,gp3,io1).
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> vms: - id: <source_vm1> - name: <source_vm2> hooks: - hook: namespace: <namespace> name: <hook> step: <step> 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. <plan>-
Specifies the name of the
PlanCR. map- Specifies the network map and storage map used by the plan.
network- Specifies a network mapping, even if the migration does not assign the virtual machines (VMs) to a network. The mapping can be empty in this case.
<network_map>-
Specifies the name of the
NetworkMapCR. storage- Specifies a storage mapping, even if the migration does not assign disk images to the VMs. The mapping can be empty in this case.
<storage_map>-
Specifies the name of the
StorageMapCR. <target_namespace>- Specifies the target namespace in OpenShift Virtualization where MTV creates the migrated VMs.
vms-
Specifies the source VMs. Accepts either the
idor thenameparameter to specify the source VMs. <source_vm1>- Specifies the EC2 instance ID.
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> EOFwhere:
<name_of_migration_cr>-
Specifies the name of the
MigrationCR. <name_of_plan_cr>-
Specifies the name of the
PlanCR to execute.
Monitor the migration progress:
$ oc get migration/<name_of_migration_cr> -n <namespace> -o yamlThis shows the migration status and progress.
View detailed migration information:
$ oc get vmimports -n <namespace>This shows the detailed phases of the VM import process.
7.3.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.
7.3.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.
7.3.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:
idorname-
Specifies a VM by using the
idkey or thenamekey.
Retrieve the
Migrationcustom resource (CR) to monitor the progress of the remaining VMs, following this example:$ oc get migration/<migration> -n <namespace> -o yaml