Building your VM image

This page helps you create a public machine image for your product to run on Compute Engine.

An image contains a boot loader, an operating system, and a root file system that is necessary for starting an instance. You can configure the image with a set of applications and services for your solution. The image is used by customers to launch a virtual machine instance in the cloud.

We recommend you start with creating an image in your development project, and then move it to your public project after your Google Partner Engineer has verified the image.

Before you begin

  1. Download the Google Cloud SDK.

Create the base solution VM

To create a custom machine image for Google Cloud Marketplace, you need to complete these steps (described in the sections that follow):

  • Use one of Google's supported base public images to create a VM and install your application-specific packages and configs.
  • Install scripts to retrieve the application user credentials, if necessary.
  • Install the open source component's license text and source code to comply with Google open source requirements.

Create a licensed VM image

  1. Use gcloud to set defaults for the Cloud SDK:

    gcloud config set project <project_id>
    gcloud config set compute/zone <zone>
  2. Create a master instance that will be used to install your software, and later, converted to an image to use on Google Cloud Marketplace. For more information about creating an instance, see Creating and starting an instance.

    gcloud compute instances create ${INSTANCE} --scopes 
  3. Install and customize the software. Include any startup scripts required, such as those for creating auth credentials using autogenerated password.

  4. Add open source license text files and source code on the VM (if applicable). Refer to the open source compliance document for requirements.

    When you've created and customized the master instance, prepare the disk which is needed to create a VM image.

  5. Clean up your disk. Creating a VM image directly from your VM will also transfer your user directories and SSH keys into your customers' VMs, so you must clean the disk that is used as the input disk when creating your VM image. To clean the disk:

    1. In the Compute Engine VM Instances menu, click the name of the instance you want to clean up, and then click Edit.

    2. Scroll down and uncheck Delete boot disk when instance is deleted and click Save. You'll need the disk to create the image.

    3. Delete the VM while preserving the disk. You will be prompted to confirm the deletion. Do not select Also delete book disk.

    4. Next, you need to create a new VM Instance. Expand the Management, disk, networking, SSH keys options.

    5. Under disk, attach the disk from your previous instance as an additional data disk. Ensure that Keep disk is selected for When deleting instance.

      You can now SSH into the instance and remove any home directories or other temporary files created during the software installation process. You will need to mount the data disk before you can access it. For more information on mounting disks, see Adding or Resizing Persistent Disks.

    6. When you're done, shutdown and delete the instance while preserving your updated data disk. Now you can create a VM image by completing the following steps.

  6. Get the license name for your solution in Partner Portal by using these steps:

    1. To edit the solution, click the solution ID.

    2. Edit the Solution Metadata.

    3. In the solution metadata, in the Licensing & Pricing section, under License name, note your license name. You use this license name later, when you use gcloud to create your image.

  7. Create a licensed image by running the following gcloud command:

    gcloud compute images create CREATE_IMAGE_NAME \
     --project PUBLIC_PROJECT_NAME \
     --source-disk projects/DEV_PROJECT_NAME/zones/SOURCE_DISK_ZONE/disks/SOURCE_DISK_NAME \
     --licenses projects/PUBLIC_PROJECT_NAME/global/licenses/LICENSE_NAME \
     --description ADD_DESCRIPTION

Test the VM image

Create a virtual machine instance with your newly created image and verify the functionality.

Also, to verify the license ID, SSH into the instance and verify that valid licenses are attached:

curl -s -H "Metadata-Flavor: Google"

Verify that Python 2.6 or greater is installed:

python -V

Verify that the following packages are installed:

gcloud --version
gsutil --version
ssh -V
ps aux | grep sshd
curl -V
ps aux | grep dhcp

Check to ensure that there are no other user directories installed on the instance except for your own, and that there are not any remaining user directories and credentials other than your own.