Soru

Zorluk: ZorDeploying and Managing Compute Engine Virtual Machines

A Lead Site Reliability Engineer is automating the provisioning of a critical background processing VM named `worker-node-01` in the `us-central1-a` zone. The VM must connect to an existing subnet named `backend-subnet`, execute a local shell script located at `/local/config/bootstrap.sh` on startup, attach a custom service account named `[email protected]`, and strictly prevent any external IP address allocation. Which `gcloud` command correctly fulfills all these operational requirements?

  1. gcloud compute instances create worker-node-01 --zone=us-central1-a --subnet=backend-subnet --no-address [email protected] --scopes=cloud-platform --metadata-from-file=startup-script=/local/config/bootstrap.shCevap
  2. B
    gcloud compute instances create worker-node-01 --zone=us-central1-a --subnet=backend-subnet --no-address [email protected] --metadata=startup-script=/local/config/bootstrap.sh
  3. C
    gcloud compute instances create worker-node-01 --zone=us-central1-a --subnet=backend-subnet --no-address --provisioning-model=SPOT --instance-termination-action=STOP [email protected] --metadata-from-file=startup-script=/local/config/bootstrap.sh
  4. D
    gcloud compute instances create worker-node-01 --zone=us-central1-a --subnet=backend-subnet --no-address --scopes=roles/owner --metadata-from-file=startup-script=/local/config/bootstrap.sh

Cevap

The command that correctly provisions the instance specifies `--metadata-from-file=startup-script=/local/config/bootstrap.sh` to upload the local script content, `--no-address` to block external public IP assignment, `--subnet=backend-subnet` for network placement, and `[email protected]` for identity management.
The correct command properly combines `--metadata-from-file` to read and attach the local startup script, `--no-address` to prohibit public IP creation, `--subnet` to place the VM in the dedicated subnetwork, and `--service-account` with `--scopes` to establish service identity.

Adım Adım Çözüm

1
Identify the proper flag for passing a local script file as startup metadata.
Recognize that `--metadata-from-file=startup-script=<path>` reads local file content, whereas `--metadata` only assigns literal string values.
Compute Engine startup scripts stored on the local administrator machine require file content injection during instance creation.
2
Verify network configuration flags for private instance deployment.
Confirm `--no-address` prevents external IP allocation while `--subnet` attaches the instance to `backend-subnet`.
Preventing external IP allocation is mandatory for internal backend resources.
3
Evaluate service account and scope assignment options.
Ensure `--service-account` specifies the full service account email and `--scopes` sets valid API access scopes rather than IAM role strings.
IAM roles cannot be assigned directly through gcloud instance creation scopes.

Anahtar Kavram

Compute Engine Instance Creation Flags and Metadata Configuration
Tahmini Süre:2m 0s
Bu soruyu puanla