Soru

Zorluk: OrtaDeploying and Managing Compute Engine Virtual Machines

A cloud engineer needs to deploy a new Compute Engine virtual machine instance that relies on a custom OS image stored in a separate centralized image-repository project. The VM must be assigned a reserved static internal IP address within a specific subnet and execute an automated initialization script upon first boot. What is the correct sequence of steps required to prepare resources, deploy the instance, and verify startup execution?

  1. 1Grant the Compute Image User role (roles/compute.imageUser) on the source image project to the service account or identity performing the deployment.
  2. 2Reserve a static internal IP address in the target VPC network subnet using gcloud compute addresses create.
  3. 3Execute gcloud compute instances create, specifying the cross-project image family/name, target subnet, reserved internal IP, and startup script metadata.
  4. 4Inspect the instance startup logs using gcloud compute instances get-serial-port-output to verify successful startup script execution.

Cevap

The correct workflow requires establishing cross-project IAM permissions (granting compute.imageUser on the source project), reserving the static internal IP address in the target subnet, executing the instance creation command with the specified parameters, and finally verifying startup script execution via the serial port output.
Deploying a Compute Engine instance with cross-project dependencies and reserved networking requires completing IAM authorization and network resource allocation first. Granting roles/compute.imageUser on the source image project ensures permission to read the image. Reserving the static internal IP address in the target subnet ensures the network resource is allocated. After these prerequisites are met, running gcloud compute instances create provisions the VM with the reserved IP and startup script. Finally, checking serial port output allows post-boot verification of the initialization process.

Adım Adım Çözüm

1
Grant cross-project IAM permissions
The deploying identity gains authorization to pull the disk image from the central image repository project.
Without roles/compute.imageUser granted on the source project, instance creation will fail due to access denied errors.
2
Reserve the static internal IP address
A specific internal IP address within the target subnet is allocated for the VM.
The static IP must exist in Compute Engine before it can be assigned via the --private-network-ip flag during instance creation.
3
Run gcloud compute instances create
The VM instance is provisioned using the reserved IP, custom image, and startup script.
This command provisions the instance using all configured resources and metadata.
4
Verify execution using get-serial-port-output
Console output logs generated by the guest OS and startup script are retrieved.
Startup script output is streamed to the serial console, providing empirical verification of script completion.

Anahtar Kavram

Cross-Project Compute Engine VM Provisioning and Initialization Workflow
Bu soruyu puanla