Import a golden image to Google Cloud


Migrating existing IT infrastructure to the cloud presents challenges, particularly when moving critical assets like golden images. Golden images are standardized, pre-configured operating systems and application stacks essential for consistent environment provisioning across development, testing, and production. Ensuring the replication of these images in Google Cloud, without losing fidelity or operational efficiency, is a top priority for many enterprises.

Migrate to Virtual Machines provides two primary migration paths that address different use cases: image import and machine image import.

  • Image import migrates individual disks, such as operating system or data volumes, into Google Cloud. This method supports rebuilding or maintaining golden images, especially when replicating a consistent base configuration across multiple instances.
  • Machine image import captures the entire virtual machine (VM) instance state, including multiple disks, configuration metadata, networking, and startup scripts. This comprehensive solution suits migrating complex workloads that require end-to-end replication.

For more information about the use cases and advantages of image import and machine image import, see Choose your import strategy.

The best migration approach depends on your workload. Some images are straightforward and well-suited for disk-level or image import, such as OS disks, database disks, or file systems. Others, with tighter interdependencies and configuration requirements, benefit from the holistic nature of machine image import. Understanding the distinctions between these options streamlines your cloud migration.

Objectives

  • Understand image import capabilities.
  • Understand machine image import capabilities.
  • Choose the appropriate migration approach for simple disk images versus complex, multi-disk VM instances.
  • Migrate golden images to Google Cloud while preserving integrity and flexibility.

Costs

This tutorial uses the following billable components of Google Cloud:

Review the pricing pages for each service to understand the costs associated with running this tutorial. Delete resources after completing the tutorial to avoid continued charges.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  5. Verify that billing is enabled for your Google Cloud project.

  6. Enable the VM Migration API on your project.
  7. Ensure that the operating system on the disk is supported by Migrate to VMs. For more information, see Supported operating systems.
  8. Ensure that the virtual disk image files you want to import are supported.
  9. Create a Cloud Storage bucket to upload your image files.
  10. Ensure that the following Identity and Access Management roles are granted. For more information, see Grant the required permissions.
    1. VM Migration Administrator
    2. VM Migration Service Agent

Image import—your precision migration tool

Image import offers a granular approach, focusing on bringing individual virtual disk images into Google Cloud. This migrates the building blocks of your VM instances. These images, usually containing operating systems, then instantiate new VM instances or create persistent disks within Google Cloud.

For more information about image import features, see Image import and machine image import.

Understand disk images

Disk images are versatile tools. You can use them to set up VM instances quickly, back up entire systems for safekeeping, or clone environments to streamline deployment. They are also ideal for testing software or performing system recovery without altering the original setup. For backups, development, or troubleshooting, disk images make managing IT tasks efficient and reliable.

VM disk images are low-level representations of storage volumes. They exist in several formats.

  • Raw disk images: raw disk images are uncompressed, direct block-level copies of entire disk volumes. They offer the highest fidelity but result in the largest file sizes. Common formats include:
    • VMDK (Virtual Machine Disk) - Recommended for faster import
    • QCOW
    • QCOW2
    • QED
    • VPC
    • VDI
    • VHDX
    • VHD
  • Sparse disk images: sparse disk images optimize storage by only storing used disk blocks. This significantly reduces storage overhead and dynamically expands as data writes. In Google Cloud, operating system and data disks are stored and used as images.

Import a golden image using image import

You can import a virtual disk image to Google Cloud using the Google Cloud console, Google Cloud CLI, or REST API commands. For information about importing images using Google Cloud CLI and REST API commands, see Import a virtual disk image to Google Cloud.

To import a virtual disk image to Google Cloud using the Google Cloud console, use the following steps.

  1. Upload your virtual disk image file to a Cloud Storage bucket. For better performance, we recommend that you upload the virtual disk image file to a bucket in the same cloud region in which you want to create the image.

  2. Open the Image imports tab in Migrate to VMs page in the Google Cloud console.

    Go to Image imports

  3. Click Create Image.

  4. Click Browse to view the list of buckets in your current project. Select the file from which you want to import the image.

  5. Define the rest of characteristics of the image. For more information on the parameters, see Import a virtual disk image.

    1. Consider using the Generalize feature for Windows images. When a VM instance is created from an image in Windows, unique information adds to that instance. The Generalize process removes this unique data, enabling you to create multiple instances from the same image.
    2. Use public image families to manage the lifecycle of your images. Ensure that you create new instances from the most up-to-date version of every image family. Add the Family field to a new image to indicate that this is the latest version of the images belonging to that family.
  6. After filling in all the parameter details and options, click Create to initiate the image import process.

  7. After the import job is created, track its status in the Migrate to VMs dashboard.

Once the import job is complete, you'll have a disk-based image.

Machine image import—the holistic migration approach

Machine images offer a comprehensive approach, providing a broader solution compared to focusing solely on individual disks. A machine image captures the configuration of an entire VM instance, including instance settings, network configurations, operating system details, metadata and labels, security configurations, as well as startup and shutdown scripts.

By importing a machine image, you bring a complete and unified blueprint of your VM instance into Google Cloud. This holistic method simplifies the migration of complex workloads, ensuring consistency and reducing the likelihood of errors during deployment.

For more information about machine image import features, see Image import and machine image import.

Import a golden image using machine image import

You can import a machine image to Google Cloud using the Google Cloud console, gcloud CLI, or REST API commands. For information about importing machine images using gcloud CLI and REST API commands, see Import a machine image to Google Cloud.

To import a machine image to Google Cloud using Google Cloud console, use the following steps:

  1. Upload your OVA or OVF file to a Cloud Storage bucket. For better performance, we recommend that you upload the virtual disk image file to a bucket in the same cloud region in which you want to create the image.

  2. Open the Machine image imports tab in Migrate to VMs page in the Google Cloud console.

    Go to Machine image imports

  3. Click Create Machine Image.

  4. Click Browse to view the list of buckets in your current project. Select the file from which you want to import the image.

  5. Define the rest of characteristics of the image. For more information on the parameters, see Import a machine image.

    Consider using the Generalize feature for Windows images. When a VM instance is created from an image in Windows, unique information adds to that instance. The Generalize process removes this unique data, enabling you to create multiple instances from the same image.

  6. After filling in all the parameter details and options, click Create to initiate the image import process.

  7. After the import job is created, track its status in the Migrate to VMs dashboard.

Once the import job is complete, you'll have a machine image.

Clean up

After you finish the tutorial, clean up the resources you created to stop incurring charges. The following sections describe how to delete or turn off these resources.

Delete the project

The easiest way to eliminate billing is to delete the project that you created for the tutorial.

To delete the project:

  1. In the Google Cloud console, go to the Manage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

Delete individual resources

If you don't want to delete the entire project, delete the individual resources created during this tutorial.

  1. Delete the bucket:
    gcloud storage buckets delete BUCKET_NAME
  2. Delete any imported images or machine images.
    gcloud compute images delete IMAGE_NAME
    gcloud compute machine-images delete MACHINE_IMAGE_NAME
  3. Delete any virtual machine instances created from the imported images.
  4. Delete the instance:
    gcloud compute instances delete INSTANCE_NAME