Migrating from Compute Engine to GKE

In this topic, you will use Migrate for Anthos to migrate VMs from Compute Engine to containers running on Google Kubernetes Engine.


Migrating from Compute Engine to GKE has several crucial differences from VMware migrations.

Setting up a cluster to perform migrations is detailed at Configuring a GKE cluster.

Building configuration files

Open Cloud Shell or a terminal

  1. Open Cloud Shell

Continue with installation

  1. Install the required dependencies.

    pip3 install --user pyyaml

  2. Open the VM Instances page on the GCP Console and Stop the Compute Engine instance you are migrating.

  3. Use the clone_vm_disks script to clone the VM's disks and generate a deployment YAML file:

    python3 /google/migrate/anthos/gce-to-gke/clone_vm_disks.py \
    -p [PROJECT_NAME] `#Your GCP project name` \
    -z [ZONE_NAME] `#GCP Zone that hosts the VM, for example us-central1-a` \
    -i [VM_NAME] `#Name of the VM. For example, myapp-vm` \
    -A [APP_NAME] `#Name of workload that will be launched in GKE` \
    -o [YAML_FILE_NAME] `#Filename of resulting YAML configuration`

Apply configuration to your cluster

To apply the deployment to your cluster, run

kubectl apply -f [YAML_FILE_NAME]

Next, open the GKE Workloads page on the Google Cloud Platform Console. Check that your Workload is running on the cluster.

Your VM is now migrated to GKE.

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.

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

Send feedback about...

Migrate for Anthos Documentation