mon
mon

Reputation: 22286

What is --image-project argument of gcloud compute instances create command?

Please help understand what is --image-project argument of the gcloud compute instances create command.

Following Architecting with Google Kubernetes Engine in Coursera. There is an instruction to create a VM as below.

It looks to me there is a project which creates and maintains the Debian Linux image for the GCP platform which is to be specified with the --image-project argument.

gcloud compute instances create $MY_VMNAME \
--machine-type "e2-standard-2" \
--image-project "debian-cloud" \      # <-----
--image-family "debian-9" \
--subnet "default"

However, not clear what the documentation means.

--image-project=IMAGE_PROJECT
The Google Cloud project against which all image and image family references will be resolved. It is best practice to define image-project. A full list of available projects can be generated by running gcloud projects list.

Running the gcloud projects list as per the documentation does not show the "debian-cloud". I think it is showing the project which the current GCP account user can access.

$ gcloud projects list

PROJECT_ID: cloudshell-images
NAME: Google Cloud Shell
PROJECT_NUMBER: 205372091086

PROJECT_ID: esoteric-quanta-324122
NAME: RMqwiklabs-gcp-02-6dae71c9f143
PROJECT_NUMBER: 313871830131

PROJECT_ID: pso-vmaas-1
NAME: pso-vmaas-1
PROJECT_NUMBER: 687834401499

PROJECT_ID: qwiklabs-gcp-02-d5ed5f282fe4
NAME: qwiklabs-gcp-02-d5ed5f282fe4
PROJECT_NUMBER: 138724239027

PROJECT_ID: qwiklabs-resources
NAME: Qwiklabs Resources
PROJECT_NUMBER: 1030115194620

Question

Is the documentation correct? Does --image-project refer to a GCP project which Debian linux people or GCP is managing the Debian VM images for GCP?

Upvotes: 1

Views: 1884

Answers (1)

Oleksandr Bushkovskyi
Oleksandr Bushkovskyi

Reputation: 825

There are two types of compute engine VM images according to the documentation:

  • Public images are provided and maintained by Google, open source communities, and third-party vendors. By default, all Google Cloud projects have access to these images and can use them to create instances.
  • Custom images are available only to your Cloud project. You can create a custom image from boot disks and other images. Then, use the custom image to create an instance.

Some Google managed projects with public images are: debian-cloud, windows-cloud, centos-cloud. In case of using public image you need to set --image-project value to public project id.

You can also create "Custom images" in one of your GCP projects. In this case you need to set --image-project value to your project id when creating inctance form custom image.

I think you are right, that this paragraph in the documentation looks incorrect, as referred command doesn't list projects with public images:

--image-project=IMAGE_PROJECT

The Google Cloud project against which all image and image family references will be resolved. It is best practice to define image-project. A full list of available projects can be generated by running gcloud projects list.

To list available images (public and custom) you can run:

gcloud compute images list

Upvotes: 2

Related Questions