Adding a migration source

Before you start migrating, you create a migration source that represents the source platform from which you will be migrating. This source is added to your migration plan.

This topic describes how to create a source for each of the supported source platforms.

Before you begin

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

Adding a migration source

Define the migration source you're migrating from by running the migctl source create command or by using the Google Cloud console. This process adds details needed to migrate from the source you specify — VMware or Compute Engine.

migctl on Google Cloud

Compute Engine

  1. Create a service account for using Compute Engine as a migration source and download the JSON key file, as described in Configuring a service account.

  2. Create the source using the service account:

    migctl source create ce SOURCE_NAME --project PROJECT_ID --json-key=COMPUTE_KEY.json

    Replace the following:

    • SOURCE_NAME: the name you want for your source
    • PROJECT_ID: your project ID
    • COMPUTE_KEY.json: the path of the service account json key used for the Compute Engine service

VMware

  1. Create a service account and download the Compute Engine JSON key file, as described in Specify the Migrate to Virtual Machines target project service account.

  2. Create a service account and download the Migrate to Virtual Machines JSON key file, as described in Specify the Migrate to Virtual Machines service account.

  3. To create the migration source, run the following command:

    migctl source create m2vm SOURCE_NAME --project PROJECT_ID --json-key M2VM_KEY.json --target-json-key COMPUTE_KEY.json --location LOCATION --m2vm-source M2VM_SOURCE
    

    Replace the following:

    • SOURCE_NAME: the name you want for the migration source
    • PROJECT_ID: the ID of the Migrate to Virtual Machines project
    • M2VM_KEY.json: the path of the service account json key used for the Migrate to Virtual Machines service
    • COMPUTE_KEY.json: the path of the service account json key used for the Compute Engine service
    • LOCATION: the Migrate to Virtual Machines service location. For example: us-central1
    • M2VM_SOURCE: the Migrate to Virtual Machines source name

migctl on Google Distributed Cloud Virtual for Bare Metal

VMware

migctl source create local-vmware local-vmware-src --vc 'VC' --username 'USERNAME' --dc VM_DC

Replace the following:

  • VC: the vCenter DNS name or vCenter IP address. For example, 1.2.3.4.
  • USERNAME: a user that has permission to access the vCenter. For example, admin. You are prompted to enter the user's password.
  • VM_DC: the vSphere datacenter for the local-vmware source. It is required in multi DC environments.

CRD

Compute Engine

  1. Create a service account and download the JSON key file, as described in Creating a service account using Compute Engine.

  2. Create a secret using the command:

    kubectl create secret generic COMPUTE_SECRET -n v2k-system --from-file=cloud-platform-service-account-key=COMPUTE_KEY.json

    Replace the following:

    • COMPUTE_SECRET: the name you want for your Compute Engine secret
    • COMPUTE_KEY.json: the name of the Compute Engine JSON file
  3. To create a migration source, create a SourceProvider file called my-source-provider.yaml:

    apiVersion: anthos-migrate.cloud.google.com/v1beta2
    kind: SourceProvider
    metadata:
      name: SOURCE_NAME
    spec:
      gce:
        project: PROJECT_ID
        serviceAccount:
          secretRef:
              name: COMPUTE_SECRET
              namespace: v2k-system
    

    Replace the following:

    • SOURCE_NAME: the name you want for your source
    • PROJECT_ID: your project ID
    • COMPUTE_SECRET: name of the secret
  4. Apply the file:

      kubectl apply -f my-source-provider.yaml

VMware

  1. Create a service account and download the Compute Engine JSON key file, as described in Creating a service account using Compute Engine.

  2. Create a Compute Engine secret using the command:

    kubectl create secret generic COMPUTE_SECRET -n v2k-system --from-file=cloud-platform-service-account-key=COMPUTE_KEY.json

    Replace the following:

    • COMPUTE_SECRET: the name you want for your Compute Engine secret
    • COMPUTE_KEY.json: the name of the Compute Engine JSON file
  3. Create a service account and download the Migrate to Virtual Machines JSON key file, as described in Specify the Migrate to Virtual Machines service account.

  4. Create a Migrate to Virtual Machines secret using the command:

    kubectl create secret generic M2VM_SECRET -n v2k-system --from-file=cloud-platform-service-account-key=M2VM_KEY.json

    Replace the following:

    • M2VM_SECRET: the name you want for your Migrate to Virtual Machines secret
    • M2VM_KEY.json: the name of the Migrate to Virtual Machines JSON file
  5. To create a migration source, create a SourceProvider file called my-source-provider.yaml:

    apiVersion: anthos-migrate.cloud.google.com/v1beta2
    kind: SourceProvider
    metadata:
      name: SOURCE_NAME
    spec:
      gce:
        project: PROJECT_ID
        serviceAccount:
          secretRef:
            name: COMPUTE_SECRET
            namespace: v2k-system
      remoteSourceSpec:
        migrateForCEService:
          location: LOCATION
          project: PROJECT_ID
          serviceAccount:
            secretRef:
              name: M2VM_SECRET
              namespace: v2k-system
          sourceName: M2VM_SOURCE
    

    Replace the following:

    • SOURCE_NAME: the name you want for your source
    • PROJECT_ID: your project ID
    • COMPUTE_SECRET: the name of the Compute Engine secret
    • LOCATION: your project location
    • M2VM_SECRET: the name of the Migrate to Virtual Machines secret
    • M2VM_SOURCE: the Migrate to Virtual Machines source name
  6. Apply the file:

  kubectl apply -f my-source-provider.yaml

Console

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

    Go to the Migrate to Containers page

  2. If you are using a remote GKE Enterprise cluster, meaning you are using Google Distributed Cloud Virtual for Bare Metal, and have not yet logged in to the cluster, log in now.

    For more on accessing remote clusters, see Logging in to a cluster from the Google Cloud console.

  3. Click the Sources tab to display a table containing the available sources.

  4. Click Add Source.

  5. Select a cluster where you have already installed the Migrate to Containers components from the drop-down list.

  6. Click Next.

  7. Specify the name of the source.

  8. Select the Source type.

  9. Click Next.

  10. Configure the source based on your selection for Source type:

    1. For Compute Engine:

      1. Select the project that contains the VM that you want to migrate.

      2. Select the service account. You can either:

        1. Create a new service account. You are prompted to enter the name of the new service account.
        2. Use an existing service account if you created one as described in Creating a service account for using Compute Engine as a migration source. When you select this option, you are prompted to enter the contents of the JSON key file associated with that service account.
  11. Click Next.

  12. Select Add Source.

After you add the source, your cluster should have a new SourceProvider.

kubectl get SourceProvider

Viewing a list of sources

You can view the list of migration sources using the migctl source list command or the Google Cloud console to confirm that you've successfully configured your environment with the migration source.

migctl

migctl source list

If a source is not in the READY state, you can get more information about the source, including any error messages, by using the command:

migctl source status SOURCE_NAME

Console

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

    Go to the Migrate to Containers page

  2. To display a table containing the available sources, click Manage sources.

Adding Migrate to Virtual Machines as a migration source

Prepare Migrate to Virtual Machines as a migration source

To use Migrate to Virtual Machines 5.0 as a migration source, you must first enable the Migrate to Virtual Machines services and install the connector, as described in the following steps:

  1. Enabling Migrate to Virtual Machines services.
  2. Installing the Migrate Connector.

Specify the Migrate to Virtual Machines service account

To use Migrate to Virtual Machines as a migration source, create a service account with the vmmigration.admin role bound on the service project:

  1. Create the m2c-m2vm-src-service service account:

    gcloud iam service-accounts create m2c-m2vm-src-service  --project=PROJECT_ID
    

    Replace PROJECT_ID with your project ID.

  2. Grant the vmmigration.admin role to the service account:

    gcloud projects add-iam-policy-binding PROJECT_ID  \
    --member="serviceAccount:m2c-m2vm-src-service@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/vmmigration.admin"
    

    Replace PROJECT_ID with your project ID.

  3. Download the key file for the service account:

    gcloud iam service-accounts keys create m2c-m2vm-src-service.json \
    --iam-account=m2c-m2vm-src-service@PROJECT_ID.iam.gserviceaccount.com \
    --project=PROJECT_ID
    

    Replace PROJECT_ID with your project ID.

Specify the Migrate to Virtual Machines target project service account

To use Migrate to Virtual Machines as a migration source, create a service account with the compute.instanceAdmin.v1 and compute.storageAdmin roles bound on the target project:

  1. Create the m2c-m2vm-src-gce service account:

    gcloud iam service-accounts create m2c-m2vm-src-gce  --project=PROJECT_ID
    

    Replace PROJECT_ID with your project ID.

  2. Grant the compute.instanceAdmin.v1 role to the service account:

    gcloud projects add-iam-policy-binding TARGET_PROJECT_ID  \
    --member="serviceAccount:m2c-m2vm-src-gce@PROJECT_ID.iam.gserviceaccount.com
    --role="roles/compute.instanceAdmin.v1"
    

    Replace PROJECT_ID with your project ID.

  3. Grant the compute.storageAdmin role to the service account:

    gcloud projects add-iam-policy-binding TARGET_PROJECT_ID  \
    --member="serviceAccount:m2c-m2vm-src-gce@PROJECT_ID.iam.gserviceaccount.com" \
    --role="roles/compute.storageAdmin"
    

    Replace PROJECT_ID with your project ID.

  4. Download the key file for the service account:

    gcloud iam service-accounts keys create m2c-m2vm-src-gce.json \
    --iam-account=m2c-m2vm-src-gce@PROJECT_ID.iam.gserviceaccount.com \
    --project=PROJECT_ID
    

    Replace PROJECT_ID with your project ID.

After downloading the service account key as a JSON file, you can create a source for migrating Migrate to Virtual Machines workloads.

What's next