Soru

Zorluk: ZorDeploying and Managing Compute Engine Virtual Machines

A Systems Administrator needs to create a standardized golden image from an existing, configured Compute Engine instance named `web-template-vm` located in GCP project `corp-base-images`. The administrator must then use this custom image to provision a new production Compute Engine instance in a separate project named `corp-prod-apps`. In what correct chronological order should the administrator perform the steps to complete this cross-project image creation and VM deployment workflow?

  1. 1Stop the reference Compute Engine instance `web-template-vm` in `corp-base-images` to ensure persistent disk data consistency.
  2. 2Create a custom Compute Engine image from the boot disk of `web-template-vm` within `corp-base-images`.
  3. 3Grant the Compute Engine Service Agent or deployer service account in `corp-prod-apps` the Compute Image User (`roles/compute.imageUser`) IAM role on the custom image in `corp-base-images`.
  4. 4Run `gcloud compute instances create` in `corp-prod-apps`, specifying the custom image name and setting `--image-project=corp-base-images`.

Cevap

The correct sequence is: First, stop the reference Compute Engine instance to ensure disk consistency. Second, create the custom image from the boot disk. Third, grant the Compute Image User role on the image/project to the target project's identity. Fourth, execute the gcloud instance creation command in the target project referencing the image and image-project flags.
To deploy a Compute Engine VM from a custom image in a separate project, the source instance must first be stopped to guarantee disk state consistency. Next, the custom image is created from the source boot disk. Then, cross-project access must be configured by granting the Compute Image User role (roles/compute.imageUser) to the deploying identity or service account in the target project. Finally, the VM can be provisioned in the target project using the gcloud command with --image and --image-project specified.

Adım Adım Çözüm

1
Prepare source disk state
Reference VM instance is powered off safely.
Creating an image from a running VM can lead to inconsistent state or file corruption.
2
Generate custom image resource
Custom image object created in the base images project.
The custom image bundles the OS, configuration, and software stack required for deployment.
3
Configure cross-project IAM permissions
Target project service account is authorized to consume the image.
Compute Engine denies image access across projects by default unless roles/compute.imageUser is granted.
4
Deploy new VM instance
New VM is provisioned in target project using the cross-project custom image.
Passing --image and --image-project parameters instructs Compute Engine to fetch the boot disk image from the central project.

Anahtar Kavram

Cross-Project Custom Image Creation and VM Provisioning
Bu soruyu puanla