Soru

Zorluk: OrtaDeploying and Managing Compute Engine Virtual Machines

A cloud administrator needs to script the deployment of a Compute Engine virtual machine instance named `backend-api` into an existing Virtual Private Cloud (VPC) subnetwork named `prod-subnet`. Additionally, the deployment script must pass key-value pairs (`env=production,role=api`) to the instance metadata server upon creation. Which of the following flags should be included in the `gcloud compute instances create` command to achieve this configuration? (Select TWO answers.)

  1. --subnet=prod-subnetCevap
  2. --metadata=env=production,role=apiCevap
  3. C
    --vpc-subnet=prod-subnet
  4. D
    --custom-variables=env=production,role=api

Cevap

The correct flags to include in the `gcloud compute instances create` command are `--subnet=prod-subnet` and `--metadata=env=production,role=api`.
Specifying `--subnet=prod-subnet` ensures the VM instance connects to the intended VPC subnetwork, while `--metadata=env=production,role=api` registers the specified key-value pairs on the instance's metadata server during creation.

Adım Adım Çözüm

1
Identify the required network configuration flag for specifying a subnetwork.
The standard `gcloud compute instances create` flag for attaching to a subnetwork is `--subnet`.
Deploying into a specific VPC subnetwork requires passing `--subnet=<subnet-name>`.
2
Identify the required metadata configuration flag for setting key-value pairs.
The standard `gcloud compute instances create` flag for setting instance metadata is `--metadata`.
Custom key-value pairs are passed to the instance metadata server using comma-separated `KEY=VALUE` entries with `--metadata`.

Anahtar Kavram

Deploying Compute Engine instances into specific subnets with custom metadata using gcloud CLI flags
Bu soruyu puanla