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

  1. 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.

  2. 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

  1. Create a Migration my-migration.yaml file to define a migration.

    In this file, the name field under sourceProviderRef specifies the name of a previously created SourceProvider and sourceId 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
  2. 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.

  3. Apply the file:

    kubectl apply -f my-migration.yaml

Console

  1. 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.

  2. Open the Migrate to Containers page in the console.

    Go to the Migrate to Containers page

  3. Click the Migrations tab to display a table containing the available migrations.

  4. Click Create Migration.

  5. Enter the Migration name.

  6. 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.

  7. Set the Workload type as Windows IIS container.

  8. Enter the source VM ID, meaning the name of the VM as it appears in the Google Cloud console.

  9. 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

  1. 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
  2. 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.

  1. 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.

  2. 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 or False when it failed.

  3. 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

  4. 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:

  1. Open the Migrate to Containers page in the console.

    Go to the Migrate to Containers page

  2. Click the Migrations tab to display a table containing the available migrations.

  3. 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.

  4. When migration creation completes, the Status displays Migration plan generated.

  5. You can now restart the Windows Compute Engine VM, if necessary. The VM must be stopped for you to create a migration.

Next Steps