Execute a migration
You begin migrating VMs with a command that generates target container artifacts and extracts them using the processing cluster you created in Installing Migrate to Containers.
This topic describes how to execute a migration to:
- Extract workload artifacts from the VM into a container image and data volume (for stateful workloads).
- Copy a container image of your VM into a container registry.
- Generate migration deployment artifacts you can use for production deployments.
Once this step has completed, you'll be able to:
Test the image and data volume (for stateful workloads) on the processing cluster.
Though you haven't yet deployed the image to a separate cluster, it is runnable and testable. Once migration is complete, the image is not connected with the source VM.
Deploy the image and data volume (for stateful workloads) to another cluster.
Before you begin
To succeed, you should have first done the following:
- Create a migration to generate a migration plan.
- Customize the migration plan according to your workload type:
- Linux - Customize the migration plan.
- Windows - Customize the migration plan.
- Tomcat - Customize the migration plan.
- WebSphere traditional - Customize the migration plan.
- JBoss - Customize the migration plan.
- WordPress - Customize the migration plan.
Execute the migration and generating artifacts
Use the migctl migration generate-artifacts
command or the Google Cloud console to generate
target container artifacts as part of processing a VM for migration.
migctl
Execute the migration:
migctl migration generate-artifacts my-migration
Get the migration status:
migctl migration status my-migration
Console
Open the Migrate to Containers page in the Google Cloud console.
Click the Migrations tab to display a table containing the available migrations.
In the row for the desired migration, select Generate artifacts in the Next steps dropdown.
View the status of a migration by:
Viewing the Status column for the row for your migration.
Clicking the migration Name. The migration Details tab opens. Click the Monitoring tab to see the detailed status, or the Events tab to see migration events.
When the Status of the migration is Artifacts generated you can move on to the next step.
CRD
Linux, Windows, and Tomcat
Get the name of the AppXGenerateArtifactsFlow using the name specified in the Migration yaml when you created the migration:
kubectl get migrations.anthos-migrate.cloud.google.com -n v2k-system my-migration -o jsonpath={.status.migrationPlanRef.name}
Create an AppXGenerateArtifactsTask
my-generate.yaml
file to define a generate artifacts task.In this file,
migration
specifies the migration name when you created the migration, andflow
represents theAppxGenerateArtifactsFlow
of the migration which you got on previous step:apiVersion: anthos-migrate.cloud.google.com/v1beta2 kind: AppXGenerateArtifactsTask metadata: name: my-migration-task namespace: v2k-system spec: migration: name: my-migration flow: name: appx-generateartifactsflow-my-migration
Apply the file:
kubectl apply -f my-generate.yaml
When you generate artifacts for workloads, Migrate to Containers writes the artifacts and then uploads them to a Cloud Storage bucket. The artifact directory file contains:
- Dockerfile - The Dockerfile used to build the image for your migrated VM.
deployment_spec.yaml
- The YAML file that configures your workload.secrets.yaml
- A secrets YAML file which contains sensitive data might also be added to the artifact directory.You can use
kubectl apply
with this file to deploy the workload to a cluster, such as a production or test cluster.Directories and files that are extracted from the source and used by the Dockerfile.
Download the generated artifacts
To download the generated container artifacts in this nested directory, run the following command:
migctl migration get-artifacts my-migration
Depending on your plugin and migration plan, the generated artifacts contain one or more dockerfiles that are used to build container images, and one or more Kubernetes deployment specs.
Additionally, Migrate to Containers generates a Skaffold configuration that you can use for quick building and deploying of all the generated images in a single step.
What's next
- Learn how to monitor a migration.