Creating a migration
You begin migrating VMs by creating a migration. Further review and customization of the generated plan is typically required before proceeding to execute the migration.
A migration is the central object with which you perform migration actions,
monitor migration activities and status with the migctl
tool. The migration
object is implemented as a Kubernetes Custom Resource Definition (CRD).
Before you begin
Migration naming requirements
You assign a name to a migration when you create it in Migrate to Containers. The name must meet the following requirements:
- Contain at most 63 characters.
- Contain only lowercase alphanumeric characters or "-" (hyphen).
- Start with an alphanumeric character.
- End with an alphanumeric character.
Creating a migration
Create a migration by running the migctl
tool or the
Google Cloud console, as described in the following examples.
migctl
Compute Engine
Stop the Compute Engine VM. The VM must be stopped for you to create a migration. After the migration completes, you can restart the VM.
Create the migration:
migctl migration create my-migration -p split-workloads --source my-ce-src --vm-id my-id --type=windows-iis-container
Where
--vm-id
specifies the name of the Compute Engine instance as shown in the Google Cloud console.
CRD
Create a Migration
my-migration.yaml
file to define a migration.In this file, the
name
field undersourceProviderRef
specifies the name of a previously created SourceProvider andsourceId
field specifies the name of the Compute Engine instance:apiVersion: anthos-migrate.cloud.google.com/v1 kind: Migration metadata: name: my-migration namespace: v2k-system spec: type: windows-iis-container sourceSnapshotTemplate: spec: sourceProviderRef: name: my-ce-src sourceId: my-id
If you are migrating a Compute Engine VM, stop the VM. The VM must be stopped for you to create a migration. After the migration completes, you can restart the VM.
Apply the file:
kubectl apply -f my-migration.yaml
Console
Stop the Windows Compute Engine VM. The VM must be stopped for you to create a migration. After the migration completes, you can restart the VM.
Open the Migrate to Containers page in the console.
Click the Migrations tab to display a table containing the available migrations.
Click Create Migration.
Enter the Migration name.
Select the migration source that you created in Adding a migration source. The type of the source must be Compute Engine and the source processing cluster must be configured to support migrating Windows VMs.
Set the Workload type as Windows IIS container.
Enter the source VM ID, meaning the name of the VM as it appears in the Google Cloud console.
Click Create Migration.
When migration creation completes, the Status column displays Migration plan generated.
Monitoring migration creation
Use the migctl
tool or the Google Cloud console
to monitor the progress of migration creation.
migctl
Wait until the migration has Completed:
migctl migration status my-migration NAME CURRENT-OPERATION PROGRESS STEP STATUS AGE my-migration GenerateMigrationPlan [1/3] CreateSourceSnapshots Running 13s
Restart the Compute Engine VM. The VM must be stopped for you to create a migration. After the migration completes, you can restart it.
CRD
Use kubectl
to get migration information and status MigrationStatus by specifying a JSONPath to the necessary field.
Wait for the migration creation phase to end:
Use two
kubectl wait
commands, one to wait for the "Ready" condition and the other for the "Failed" condition. The migration plan creation phase is running until the first condition is met.unset pids; for cond in "Ready" "Failed"; do kubectl wait migrations.anthos-migrate.cloud.google.com my-migration -n v2k-system --for condition=$cond --timeout=15m & pids+=($!); done; wait -p met_pid -n ${pids[@]} kill ${pids[@]/$met_pid} # terminate the process that did not complete.
When the wait command completes, the operation has completed, you can move on to the next step.
Get the migration plan status:
kubectl get migrations.anthos-migrate.cloud.google.com -n v2k-system -o jsonpath={.status.conditions[?(@.type==\"Ready\")].status} my-migration
Returns
True
when the migration plan is ready orFalse
when it failed.When the migration plan fails, use the following command to get the error message:
kubectl get migrations.anthos-migrate.cloud.google.com -n v2k-system -o jsonpath={.status.conditions[?(@.type=="Ready")].message} my-migration
If you are migrating a Compute Engine VM, then restart it. A stopped VM is not required after this step.
Console
When the migration status shows that the migration has been created, you can move on to the next step:
Open the Migrate to Containers page in the console.
Click the Migrations tab to display a table containing the available migrations.
View the status of a migration by:
Viewing the Status column for the row for your migration.
Clicking the migration name. The Migration details page opens. Click the Monitoring tab to see the detailed status, or the Events tab to see migration events.
When migration creation completes, the Status displays Migration plan generated.
You can now restart the Windows Compute Engine VM, if necessary. The VM must be stopped for you to create a migration.