Migrating VMware VMs to GKE

After your GKE cluster is configured, you can migrate your VMs to GKE using Migrate for Anthos. This will take place in three steps:

  1. Finding configuration details for the VMs you want to migrate and creating a YAML configuration.
  2. Applying that configuration to your cluster using kubectl apply, which begins the migration process.
  3. Connecting to the container using kubectl exec. You can roll back your migration if tests are not successful.

Migrating from VMware to GKE


You will need two values to proceed:

  1. The StorageClassName from your cluster's environment. For example, csi-vlsdisk-sc01. This was defined when you created your Migrate for Anthos deployment.
  2. 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

The MoRef can also be found using PowerCLI

Building configuration files

Details on VMs migrated with Migrate for Anthos are configured in a YAML file. The template is available here, and is reproduced below.

kind: PersistentVolumeClaim
apiVersion: v1
  name: [PVC_NAME]
    # Replace vlsVmMoref with application's VM ID
    pvc.csi.kubernetes.io/vlsVmMoref: [VM_ID]
    pvc.csi.kubernetes.io/vlsVmDataAccessMode: "Streaming"
    pvc.csi.kubernetes.io/vlsRunMode: "TestClone"
  - ReadWriteOnce
  # Replace with your Storage Class name defined when adding Migrate for Anthos to your cluster
  storageClassName: [STORAGE_CLASS_NAME]
      storage: 1Gi

kind: StatefulSet
apiVersion: apps/v1beta1
  namespace: default
  serviceName: [SERVICE_NAME]
  replicas: 1
        app: [APPLICATION_NAME]
        anthos-migrate.gcr.io/action: run
        anthos-migrate.gcr.io/source-type: vlsdisk
        # source-pvc needs to match the name of the PVC declared above.
        anthos-migrate.gcr.io/source-pvc: [PVC_NAME]
      - name: [APPLICATION_NAME]
      # The image for the Migrate for Anthos system container.
        image: anthos-migrate.gcr.io/v2k-run:v0.9.6
  1. Download the template or copy the YAML into an editor. For more information on the YAML's contents, see YAML reference.
  2. Open the YAML. There are two sections to edit.

    1. Find the PersistentVolumeClaim section.
    2. Replace the value ofpvc.csi.kubernetes.io/vlsVmMoref with your VM's VMware ID.
    3. Replace StorageClassName with the name from the environment configuration YAML you used in configuring your cluster.
    4. Find the StatefulSet section.
    5. Name your GKE workload by updating the name field under metadata.

    6. If you would like to fully cache volumes on GCP after starting them on GKE, change the value of pvc.csi.kubernetes.io/vlsVmDataAccessMode to FullyCached.

    7. Save the file.

  3. Apply the YAML to your cluster

    kubectl apply -f [DEPLOYMENT_YAML]
  4. Open the GKE Workloads page on the Google Cloud Platform Console.

  5. Check that your Workload is running on the cluster.

Checking your container without SSH

You can open a shell prompt on a container using kubectl exec.

First, find the name of the Pod in your cluster that you want to connect to. In the example below, the Name of the Pod is suitecrm-0

kubectl describe pods | grep Name

Name:               suitecrm-0

Then, execute the bash shell in an interactive prompt.

kubectl exec -it [POD_NAME] -- /bin/bash

For more information, see the Kubernetes documentation.

My workload won't start

See Troubleshooting.

Was this page helpful? Let us know how we did:

Send feedback about...

Migrate for Anthos Documentation