Creating a migration

To begin migrating a workload, start by creating a migration. Further review and customization of the generated plan is typically required before proceeding to execution. A migration is the central object where 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

Compute Engine

VMware

  • vmId -- ID or name of the VM to migrate as it is known on the source platform. You can use one of the following values.

    • The VM name. If you're confident that each VM name is unique across your VMware deployment, the simple VM name works. If VM names might be duplicated, use the VM ID as described below.

      You can get the VM name from the vSphere web client, as shown in the following image.

    • The VM ID from vSphere (also called a MoRef). This is visible from the URL of the vSphere web client when selecting the VM.

      The MoRef is in the URL from vSphere

      You can find also the MoRef by using PowerCLI.

AWS

The Instance ID in the Amazon EC2 console

Azure

  • vmId -- The Azure VM resource ID for your source VM. To get this value, you can:

    1. Access and log in to the Azure Portal.
    2. In the navigation panel on the left, click Virtual Machines.
    3. On the Virtual Machines page, click the name of your VM.
    4. On your VM's page, in the navigation panel, click Properties.
    5. In the Properties page, locate the Resource ID value.

      The resource ID in the Azure portal

    6. Use the Resource ID value.

Migration naming requirements

You assign a name to a migration source when you add it to 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.

Create a migration

Create a migration by using migctl or the Google Cloud console.

migctl on Google Cloud

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 --source my-ce-src --vm-id my-id --type tomcat-container

Where --vm-id specifies the name of the Compute Engine instance as shown in the Google Cloud console.

VMware

migctl migration create my-migration --source my-vmware-src --vm-id My_VMware_VM --type tomcat-container

Where --vm-id specifies the name of the VM instance. You can specify either the VM name, such as MyVM2, or the VM MoRef ID (Managed Object Reference ID), such as vm-14. See Before you begin for more on determining the VM ID.

AWS

migctl migration create my-migration --source my-aws-src --vm-id i-1234567890abcdef0 --type tomcat-container

Where --vm-id specifies the name of the VM instance. The name of the VM instance is shown in the AWS UI and is in form i-##########. See Before you begin for more on determining the VM ID.

Azure

migctl migration create my-migration --source my-azure-src
--type tomcat-container --vm-id /subscriptions/a1b5c3d4-c3d9-a1a2-e5f6-a1t2c3d4k5f6/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/my-virtual-machine 

Where --vm-id specifies the name of the VM instance. The name of the VM instance is shown in the Azure UI. See Before you begin for more on determining the VM ID.

migctl on VMware

migctl migration create my-migration --source local-vmware-src --vm-id My_VMware_VM --type tomcat-container

Where --vm-id specifies the name of the VM instance. You can specify either the VM name, such as MyVM2, or the VM MoRef ID (Managed Object Reference ID), such as vm-14. See Before you begin for more on determining the VM ID.

migctl on AWS

migctl migration create my-migration --source local-aws-src --vm-id My_AWS_VM --type tomcat-container

Where --vm-id specifies the name of the AWS instance. See Before you begin for more on determining the VM ID.

Console

  1. If the migration source is a Compute Engine VM, 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. 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.

  7. Set the Workload type as Tomcat container.

  8. Enter the source VM ID. See Before you begin for more on determining the VM ID.

  9. Click Create Migration.

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

CRD

This example takes the values of CATALINA_BASE and CATALINA_HOME from bread crumbs left on the VM after using the fit assessment tool. Use the next example if the tool was not used.

  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 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: tomcat-container
    sourceSnapshotTemplate:
      spec:
        sourceId: my-ce-src
        sourceProviderRef:
          name: 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

If you want to manually specify the values forCATALINA_BASE and CATALINA_HOME, use the following instructions. Note that if you provide either of these values, the fit assessment collection will not be used.

migctl on Google Cloud

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 --source my-ce-src --vm-id my-id
    --type tomcat-container --parameters catalina-base=/catalina/base/path/,catalina-home=/catalina/home/path/
    

    Where --vm-id specifies the name of the Compute Engine instance as shown in the Google Cloud console.

VMware

migctl migration create my-migration --source my-vmware-src --vm-id My_VMware_VM
--type tomcat-container --parameters catalina-base=/catalina/base/path/,catalina-home=/catalina/home/path/

Where --vm-id specifies the name of the VM instance. You can specify either the VM name, such as MyVM2, or the VM MoRef ID (Managed Object Reference ID), such as vm-14. See Before you begin for more on determining the VM ID.

AWS

migctl migration create my-migration --source my-aws-src --vm-id i-1234567890abcdef0
--type tomcat-container --parameters catalina-base=/catalina/base/path/,catalina-home=/catalina/home/path/

Where --vm-id specifies the name of the VM instance. The name of the VM instance is shown in the AWS UI and is in form i-##########. See Before you begin for more on determining the VM ID.

Azure

migctl migration create my-migration --source my-azure-src
--vm-id /subscriptions/a1b5c3d4-c3d9-a1a2-e5f6-a1t2c3d4k5f6/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/my-virtual-machine
--type tomcat-container --parameters catalina-base=/catalina/base/path/,catalina-home=/catalina/home/path/

Where --vm-id specifies the name of the VM instance. The name of the VM instance is shown in the Azure UI. See Before you begin for more on determining the VM ID.

migctl on VMware

migctl migration create my-migration --source local-vmware-src --vm-id My_VMware_VM
--type tomcat-container --parameters catalina-base=/catalina/base/path/,catalina-home=/catalina/home/path/

Where --vm-id specifies the name of the VM instance. You can specify either the VM name, such as MyVM2, or the VM MoRef ID (Managed Object Reference ID), such as vm-14. See Before you begin for more on determining the VM ID.

migctl on AWS

migctl migration create my-migration --source local-aws-src --vm-id My_AWS_VM
--type tomcat-container --parameters catalina-base=/catalina/base/path/,catalina-home=/catalina/home/path/

Where --vm-id specifies the name of the AWS instance. See Before you begin for more on determining the VM ID.

CRD

  1. Set the tomcat-container appxplugin default values of CATALINA_BASE and CATALINA_HOME.

    Create patch-tomcat-container.yaml file, assuming both CATALINA_BASE and CATALINA_HOME values are /opt/tomcat

    spec:
      defaultArguments:
        - name: catalina-base
          value: /opt/tomcat
        - name: catalina-home
          value: /opt/tomcat
    

    Apply the patch using:

    kubectl -n v2k-system  patch appxplugins.anthos-migrate.cloud.google.com tomcat-container -n v2k-system --type merge --patch-file patch-tomcat-container.yaml

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

    In this file, sourceProvider 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: tomcat-container
    sourceSnapshotTemplate:
      spec:
        sourceId: my-ce-src
        sourceProviderRef:
          name: my-id
  3. 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.

  4. Apply the file:

    kubectl apply -f my-migration.yaml

Monitor status

Use the migctl or the Google Cloud console to monitor the status of migration creation.

migctl Google Cloud

  1. Wait for the migration plan creation phase to end:

    migctl migration status my-migration
    
    NAME          TYPE              SOURCE            CURRENT-OPERATION      PROGRESS  STEP                   STATUS   AGE
    my-migration  tomcat-container  gcp: "my-ce-src"  GenerateMigrationPlan  [1/3]     CreateSourceSnapshots  Running  13s 
  2. If you are migrating a Compute Engine VM, then restart it. The VM must be stopped for you to create a migration.

migctl on VMware

Wait until the migration plan creation phase has Completed:

migctl migration status my-migration

NAME          TYPE              SOURCE                         CURRENT-OPERATION      PROGRESS  STEP                   STATUS   AGE
my-migration  tomcat-container  local-vmware: "my-vmware-src"  GenerateMigrationPlan  [1/3]     CreateSourceSnapshots  Running  13s 

migctl on AWS

Wait until the migration plan creation phase has Completed:

migctl migration status my-migration

NAME          TYPE              SOURCE                      CURRENT-OPERATION      PROGRESS  STEP                   STATUS   AGE
my-migration  tomcat-container  local-aws: "local-aws-src"  GenerateMigrationPlan  [1/3]     CreateSourceSnapshots  Running  13s 

Console

When migration status show 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. If you are migrating a Compute Engine VM, then restart it. The VM must be stopped for you to create a migration.

CRD

Use kubectl to get migration information and status MigrationStatus by specifying a JSONPath to the necessary field.

  1. Wait for the migration plan 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. The VM must be stopped for you to create a migration.

Next Steps

Customize the migration plan.