0
votes

I am using new "beta" featured "Machine Image" functionality from GCP VM instance. I would also like to export that image to GCP storage bucket. But I am not getting this option either in portal UI or from gcloud sdk command prompt. When I tried to use the below command, it is failing to find the image from "Machine Images" repository. As I checked all the input parameter names are correct.

gcloud beta compute images export --destination-uri gs://vmimgbkpbucket/testvmimgbkp.tar.gz --image testvmimgbkp --project $PROJECT_ID 

Any help on this?

2

2 Answers

1
votes

If you are asking about export functionality for the machine images, this feature is currently not available.

For example: The "storage-location" in machine images only specifies where the machine image data should be stored geographically. It is either a Cloud Storage multiregional location, such as "asia", or a Cloud Storage regional location, such as "asia-south1". This flag doesn't take a storage bucket as a value and Google Cloud currently doesn't provide a way to save a machine image as a file.

If you are interested in this feature then please file a feature request .

0
votes

Edit:

I originally thought OP was confused with how this feature works (which OP sort of is) but I see now that they want to specifically export the machine image which is made. This is not possible. The feature to export currently does not exist. [source]

I'll leave the original response which describes what you can do.

Original:

You are confusing two different things:

  1. Custom Images
  2. Machine Images

Custom images capture the contents of a single disk, for example, a boot disk, which can be used to create new instances that are preconfigured with the apps that you need, so that you don’t have to configure public images from scratch.

Machine images are a more comprehensive resource that can contain multiple disks, as well as all of the information required to capture and create a new instance, including:

  • Instance properties (machine type, labels, volume mapping, network tags)
  • Data of all attached disks (one or multiple)
  • Instance metadata
  • Permissions, including the service account used to create the instance

[source]

To create a Machine Image, you should do the following:

gcloud beta compute machine-images create MACHINE_IMAGE_NAME \
    --source-instance SOURCE_INSTANCE_NAME

You can optionally add Machine Image Storage Location, otherwise:

By default, when creating a machine image from an instance, the machine image is stored in either the Cloud Storage multiregional bucket that contains the source instance, or the geographically closest Cloud Storage multiregional bucket to the source instance.