Checkpoints
Create the source Compute Engine (source-vm)
/ 20
Create a processing cluster
/ 30
Verify creation of my-service through migration
/ 50
Migrate to Containers: Qwik Start
- GSP682
- Overview
- Setup and requirements
- Task 1. Create the source Compute Engine
- Task 2. Create a processing cluster
- Task 3. Install Migrate to Containers
- Task 4. Migrating the VM
- Task 5. Migrate the VM using the migration plan
- Task 6. Deploying the migrated workload
- Task 7. Test the migration
- Congratulations!
- End your lab
GSP682
Overview
VM instances can exist on premises, managed by products such as VMWare vSphere, and in public clouds such as AWS or Azure, in addition to Google Cloud Compute Engine instances.
Anthos is an open source application platform that enables you to modernize your existing applications in your hybrid or multi-cloud environment. You can build new VMs and run them anywhere in a secure manner. Anthos is built on open source technologies pioneered by Google — including Kubernetes, Istio, and Knative — and enables consistency between on-premises and cloud environments.
When workloads are upgraded to containers, IT departments can eliminate OS-level maintenance and security patching for VMs and automate policy and security updates at scale. Monitoring across on-premises and cloud environments is done through a single interface in the Cloud Console.
Migrate to Containers provides an almost real-time solution to take an existing VM and make it available as a Kubernetes hosted pod with all the values associated with executing your applications in a Kubernetes cluster.
In this lab you create a simple Compute Engine virtual machine (VM), then use Migrate to Containers to migrate the VM to a GKE processing cluster in the Cloud.
You can perform the steps using either the migctl
tool or the Cloud Console. migctl
is a command-line tool for setting up and managing a Migrate to Containers migration environment on Google Cloud. migctl
is available in Cloud Shell.
How Migrate to Containers allows you to containerize faster than other possibilities:
Objectives
You will learn how to perform the following tasks:
- Create a Compute Engine instance hosting a Web Server.
- Create a GKE cluster to host the migrated Compute Engine instance.
- Migrate the Compute Engine instance using Migrate to Containers.
- Test the Web Server that exists in GKE.
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud console
-
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
- The Open Google Cloud console button
- Time remaining
- The temporary credentials that you must use for this lab
- Other information, if needed, to step through this lab
-
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account. -
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}} You can also find the Username in the Lab Details panel.
-
Click Next.
-
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}} You can also find the Password in the Lab Details panel.
-
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges. -
Click through the subsequent pages:
- Accept the terms and conditions.
- Do not add recovery options or two-factor authentication (because this is a temporary account).
- Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
- Click Activate Cloud Shell at the top of the Google Cloud console.
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
- Click Authorize.
Output:
- (Optional) You can list the project ID with this command:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
- Set an environment variable for your Project ID:
Task 1. Create the source Compute Engine
- Run the following command to create and configure a Compute Engine instance that will act as the source of the VM to be migrated:
You have installed the Apache web server and created a basic web page via the startup script.
Sample output:
- Create a firewall rule to allow the HTTP:
Sample output:
Click Check my progress to verify the objective.
-
In the Cloud Console navigate to Compute Engine > VM instances and locate the row for the instance you created and copy the External IP address.
-
Paste the instance's IP address to your browser address bar. Prefix it with
http://
.
You should now see the "Hello World" page.
To migrate the VM, first stop it from running..
- In the Cloud Console navigate to Compute Engine > VM instances, check the checkbox to the left of the
source-vm
then click the STOP button on the top.
- Confirm the shutdown by clicking Stop in the pop-up window. You can continue to the next section while the VM is shutting down.
migctl migration create
command.
Task 2. Create a processing cluster
In the following steps you'll create a GKE cluster in the Cloud that you'll use as a processing cluster. This is where you'll install Migrate to Containers and execute the migration.
- In Cloud Shell use the following command to create a new Kubernetes cluster to use as a processing center:
Sample output:
Click Check my progress to verify the objective.
Task 3. Install Migrate to Containers
To allow Migrate to Containers to access Container Registry and Cloud Storage you need to create a service account with the storage.admin
role.
- In Cloud Shell create the
m4a-install
service account:
- Grant the
storage.admin
role to the service account:
- Download the key file for the service account:
- Connect to the cluster:
- Set up Migrate to Containers components on your processing cluster by using the
migctl
command-line tool included with Migrate to Containers:
- Validate the Migrate to Containers installation. Use the
migctl doctor
command to confirm a successful deployment:
It may take more than a minute before the command returns the following success result.
Sample output:
- Re-run the command until you see the successful deployment.
Task 4. Migrating the VM
Now you'll create a migration plan with migration details, then use it to migrate the VM.
To use Compute Engine as a migration source, you must first create a service account with the compute.viewer
and compute.storageAdmin
roles:
- In Cloud Shell create the
m4a-ce-src
service account:
- Grant the
compute.viewer
role to the service account:
- Grant the
compute.storageAdmin
role to the service account:
- Download the key file for the service account:
- Create the migration source:
Where m4a-ce-src.json
specifies the service account you created above.
Create a migration
You begin migrating VMs by creating a migration. This results in a migration plan object.
A migration is the central object with which you perform migration actions, monitor migration activities and status with the migctl tool or in the Cloud Console. The migration object is implemented as a Kubernetes Custom Resource Definition (CRD).
Next you will create a migration by running the migctl
tool.
- Create the migration plan that defines what to migrate:
Sample output:
- Run the following to check the status:
When the status shows that the migration has the Completed status you can move on to the next step.
Review the migration plan
- For this lab, you will use the migration default plan. You will now download the migration plan to just to review it:
- Open the
my-migration.yaml
file in your preferred text editor or the Cloud Shell code editor to review.
If you need to make changes, you would upload the new plan with migctl migration update my-migration
command.
Task 5. Migrate the VM using the migration plan
- This command will migrate the VM and generate artifacts you can use to deploy the workload:
Sample output:
- After the migration begins, check its status by running the following:
The migration can take several minutes.
- Re-run the command until you see the Completed status.
- You can add
-v
flag for verbosity:
Task 6. Deploying the migrated workload
In the following steps you'll get the deployment artifacts you generated during migration, then use them to deploy your migrated workload to the cluster. As a last step, you'll confirm that the "Hello World!" web page is available from your migrated app.
- Once the migration is complete, get the generated YAML artifacts:
The command downloads files that were generated during the migration:
-
deployment_spec.yaml -- The YAML file that configures your workload.
-
Dockerfile -- The Dockerfile used to build the image for your migrated VM.
-
migration.yaml -- A copy of the migration plan.
-
blocklist.yaml -- The list of container services to disable based on your settings in the migration plan.
-
If the Cloud Shell editor isn't open already, click the Open Editor button.
-
Open the deployment_spec.yaml file and locate the
Service
object whose name issource-vm
. -
Beneath the following
Service
definition, add anotherService
at the end that will expose port 80 for access to your web server over HTTP:
Your file should look like this:
-
Save the file.
-
Apply the
deployment_spec.yaml
to deploy the workload:
Sample output:
It may take a few minutes for the deployment to finish.
- Now check for an external IP address:
Sample output:
When the web server is ready, you'll see an external IP address for the my-service
you added.
Task 7. Test the migration
- Test the migration by opening a browser and visiting the web page at the external IP address of
my-service
(be sure to use HTTP rather than HTTPS).
For example:
Click Check my progress to verify the objective.
Congratulations!
You migrated a Compute Engine instance to a Kubernetes pod using Migrate to Containers. This same technique can be used for other sources of VMs including VMWare vSphere, AWS, and Azure.
Finish your quest
This self-paced lab is part of the VM Migration quest. A quest is a series of related labs that form a learning path. Completing a quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Enroll in any quest that contains this lab and get immediate completion credit. Refer to the Google Cloud Skills Boost catalog for all available quests.
Take your next lab
Next steps / Learn more
- Documentation for Migrating VMs to Google Kubernetes Engine
End your lab
When you have completed your lab, click End Lab. Your account and the resources you've used are removed from the lab platform.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
- 1 star = Very dissatisfied
- 2 stars = Dissatisfied
- 3 stars = Neutral
- 4 stars = Satisfied
- 5 stars = Very satisfied
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Manual Last Updated: November 18, 2022
Lab Last Tested: June 6, 2022
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.