Customizing a migration plan

You should review the migration plan file resulting from creating a migration, and customize it before proceeding to executing the migration. The details of your migration plan will be used to extract the workload container artifacts from the source VM, and also to generate Kubernetes deployment files that you can use to deploy the container image to other clusters, such as a production cluster.

This section describes the migration plan's contents and the kinds of customizations you might consider before you execute the migration and generate deployment artifacts.

Before you begin

  • This topic assumes that you've already created a migration and have the resulting migration plan file.

Editting the migration plan

Edit the migration plan by using the migctl tool or the GCP Console.

migctl

You must download the migration plan before you can edit it:

  1. Download the migration plan. The migration plan is represented by GenerateArtifactsFlow:

    migctl migration get my-migration
    
  2. Edit the downloaded migration plan, my-migration.yaml, in a text editor.

  3. When your edits are complete, upload the editted migration plan:

    migctl migration update my-migration --file my-migration.yaml
    
  4. Repeat these steps if more edits are necessary.

Console

Edit the migration plan in the UI by using the YAML editor. The migration plan is represented by GenerateArtifactsFlow:

  1. Open the Migrate for Anthos page in the Cloud Console.

    Go to the Migrate for Anthos page

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

  3. In the row for the desired migration, select Review and edit migration plan in the Next steps dropdown.

  4. Edit the migration plan as necessary.

  5. When you are done editing, you can either:

    1. Save the migration plan. You then have to manually execute the migration to generate the migration artifacts using the procedure shown in Executing a migration.

    2. Save and generate the artifacts. Execute the migration by using your edits to generate the migration artifacts. The process is the same as described in Executing a migration. You can then monitor the migration as described in Monitoring a migration.

CRD

You must download the migration plan, edit it, the apply it. The migration plan is represented by GenerateArtifactsFlow:

  1. Get the name of the GenerateArtifactsFlow:

    kubectl get migrations.anthos-migrate.cloud.google.com -n v2k-system my-migration -o jsonpath={.status.resources.generateArtifacts.name}

    The name is returned in the form generate-artifacts-flow-id.

  2. Get the GenerateArtifactsFlow by name and write to a file named my-plan.yaml:

    kubectl get generateartifactsflows.anthos-migrate.cloud.google.com -n v2k-system generate-artifacts-flow-id -o yaml > my-plan.yaml
  3. Edit the migration plan as necessary.

  4. Apply the file:

    kubectl apply -f my-plan.yaml

Impact of Intent on migration plan

The contents of the migration plan you generated will differ depending on the kind of migration you created with the Intent flag.

This topic describes the purpose of each migration plan section. Each section indicates which Intent value is relevant for YAML in the section. For more information on using the Intent flag, see Creating a migration.

Specifying content to exclude from the migration

Intent: Any

By default, Migrate for Anthos will exclude typical VM content that isn't relevant in the context of GKE. You can customize that filter.

The filters field value lists paths that should be excluded from migration and will not be part of either the container image or the data volume. The field's value lists rsync filter rules that specify which files to transfer and which to skip. Preceding each path and file with a minus sign specifies that the item in the list should be excluded from migration. The list is processed according to the order of lines in the YAML, and exclusions/inclusions are evaluated accordingly.

For more, see the INCLUDE/EXCLUDE PATTERN RULES section of the rsync man page

You can edit this list to add or remove paths.

  global:
      # Files and directories to exclude from the migration, in rsync format
      filters:
      - "- *.swp"
      - "- /etc/fstab"
      - "- /boot/"
      - "- /tmp/*"
      - "- /var/log/*.log*"
      - "- /var/log/*/*.log*"
      - "- /var/cache/*"

Setting handling for the data volume

Intent: Data or ImageAndData

The dataVolumes field specifies a list of folders to include in the data volume as part of the migration. You must edit this list for a migration with an intent of Data or ImageAndData.

By default, folders contains a placeholder value that you must change. If you do not change the placeholder value, you will get an error when you generate the migration artifacts, in the form Replace the folder placeholder with the relevant path:

        dataVolumes:
        
        # Folders to include in the data volume, e.g. "/var/lib/mysql"
        # Included folders contain data and state, and therefore are automatically excluded from a generated container image
        # Replace the placeholder with the relevant path and add more items if needed
        - folders:
          - <folders>

Shown below is an example that specifies a list of folders to include in the data volume:

        - folders:
          - /var/lib/mysql
          - /my-data-folder

Setting the migration's name and namespace

Intent: Any

Using the metadata field, you can specify the name and namespace for the migration. By default, Migrate for Anthos uses the values you specified when you created the migration. (You should not change the kind and apiVersion values.) The fields are the same for all intent values.

  • name -- Name of the migration.
  • namespace -- Namespace for the migration defined in this YAML file. It should be v2k-system.
  apiVersion: anthos-migrate.cloud.google.com/v1beta2
  kind: GenerateArtifactsFlow
  metadata:
    name: generate-artifacts-flow-id
    namespace: v2k-system

Setting the name of the container image

Intent: Image or ImageAndData

The image field value defines the names and locations of two images created from a migrated VM. You can change these values if you prefer to use other names.

During migration, Migrate for Anthos copies files and directories representing your migrating workload to (by default) Container Registry for use during migration. The migration process adapts the extracted workload to an image runnable on GKE.

Migrate for Anthos preserves files and directories from the original VM (at the base path) in the registry. This image functions as a non-runnable base layer that includes the extracted workload files, which is then combined with the Migrate for Anthos runtime software layer to build an executable container image.

The use of separate layers simplifies later updates to the container image by allowing separate updates to the base layer or to the Migrate for Anthos software layer, as needed.

This image isn't runnable, but makes it possible for Migrate for Anthos to update the container from that original when you upgrade Migrate for Anthos.

The base and name field values specify images that will be created in the registry.

  • base -- Name of the image that will be created from the VM files and directories copied from the source platform. This image will not be runnable on GKE because it hasn't been adapted for deployment there.
  • name -- Name of the runnable image that will be used for the container. This image contains both the content from the source VM, and the Migrate for Anthos runtime, which allows it to be runnable.
        image:
          # Review and set the name for extracted non-runnable base image,
          # if an image tag is not specified, a random tag will be auto-generated when the image is built.
          base: "gcr.io/my-project/centos-mini-non-runnable-base"

          # Review and set the name for runnable container image,
          # if an image tag is not specified, a random tag will be auto-generated when the image is built.
          name: "gcr.io/my-project/centos-mini"

By default, a tag corresponding to the timestamp of the migration is automatically applied to these values. This tag is in the form:

MM-DD-YYYY--hh:mm:ss

To apply your own tag, overriding the default tag, edit the CRD and add it as shown below:

        image:
          # Review and set the name for extracted non-runnable base image,
          # if an image tag is not specified, a random tag will be auto-generated when the image is built.
          base: "gcr.io/my-project/centos-mini-non-runnable-base:tag"

          # Review and set the name for runnable container image,
          # if an image tag is not specified, a random tag will be auto-generated when the image is built.
          name: "gcr.io/my-project/centos-mini:tag"

Setting the Cloud Storage location for deployment artifacts

Intent: Any

During migration, Migrate for Anthos uses Cloud Storage to store files that you'll later use to deploy your VM on a production cluster. You can change the bucket and folder names to use your own.

  • bucket -- Name of the Cloud Storage bucket in which to store artifacts.
  • folder -- Name of the folder inside bucket in which to store artifacts.
  • appName -- Name to give the Kubernetes controller to use in the deployment file. The type of controller will differ based on the value you specified for the intent flag when you created the migration:
    • For an image-and-data value, the result will be a StatefulSet object with this name.
    • For an image value, the result will be a Deployment object with this name.
        deployment:
 
         # Review and set the app-name for your StatefulSet or Deployment YAML spec
         appName: app-centos-mini

         # Artifacts will be uploaded to the project-default artifacts repository.
         # In order to specify a custom repository, uncomment the lines below and replace the placeholders with the relevant values
         # artifactsRepository:
         #   spec:
         #     bucket: bucket_name
         #     credentials:
         #       type: gcs
         #       secret: secret

         folder: storage-folder-name/

Configuring persistent storage

Intent: Data or ImageAndData

For Data or ImageAndData migration intents, the migration plan includes a pvc definition with default values. You can change these values to match the needs of your system.

   pvc:
     spec:
       accessModes:
       - ReadWriteOnce
       resources:
         requests:
         # Modify the required disk size on the storage field below based on the capacity needed
           storage: 10G

Next Steps