After your GKE cluster is configured, you can migrate your VMs to GKE using Migrate for Anthos. This will take place in three steps:
- Finding configuration details for the VMs you want to migrate and creating a YAML configuration.
- Applying that configuration to your cluster using
kubectl apply, which begins the migration process.
- 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:
StorageClassNamefrom your cluster's environment. For example,
csi-vlsdisk-sc01. This was defined when you created your Migrate for Anthos deployment.
- 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 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 metadata: name: [PVC_NAME] annotations: # 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" spec: accessModes: - ReadWriteOnce # Replace with your Storage Class name defined when adding Migrate for Anthos to your cluster storageClassName: [STORAGE_CLASS_NAME] resources: requests: storage: 1Gi --- kind: StatefulSet apiVersion: apps/v1beta1 metadata: name: [APPLICATION_NAME] namespace: default spec: serviceName: [SERVICE_NAME] replicas: 1 selector: matchLabels: app: [APPLICATION_NAME] template: metadata: labels: app: [APPLICATION_NAME] annotations: 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] spec: containers: - name: [APPLICATION_NAME] # The image for the Migrate for Anthos system container. image: anthos-migrate.gcr.io/v2k-run:v0.9.6
- Download the template or copy the YAML into an editor. For more information on the YAML's contents, see YAML reference.
Open the YAML. There are two sections to edit.
- Find the
- Replace the value of
pvc.csi.kubernetes.io/vlsVmMorefwith your VM's VMware ID.
StorageClassNamewith the name from the environment configuration YAML you used in configuring your cluster.
- Find the
Name your GKE workload by updating the
If you would like to fully cache volumes on GCP after starting them on GKE, change the value of
Save the file.
- Find the
Apply the YAML to your cluster
kubectl apply -f [DEPLOYMENT_YAML]
Open the GKE Workloads page on the Google Cloud Platform Console.
Check that your Workload is running on the cluster.
Checking your container without SSH
You can open a shell prompt on a container using
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
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