A DevOps engineer is configuring an automated script to deploy a fault-tolerant batch processing Virtual Machine on Compute Engine using the gcloud CLI. The instance must run as a Spot VM to reduce compute costs, automatically terminate during host maintenance events, attach an existing custom service account named [email protected] with full Cloud Storage permissions, and execute a local shell script located at /scripts/setup.sh upon startup. Which gcloud compute instances create command correctly fulfills all these requirements?
- gcloud compute instances create batch-node-01 --zone=us-central1-a --provisioning-model=SPOT --on-host-maintenance=TERMINATE --service-account=batch-processor@my-project.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.full_control --metadata-from-file=startup-script=/scripts/setup.shCevap
- Bgcloud compute instances create batch-node-01 --zone=us-central1-a --provisioning-model=SPOT --on-host-maintenance=MIGRATE --service-account=batch-processor@my-project.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.full_control --metadata-from-file=startup-script=/scripts/setup.sh
- Cgcloud compute instances create batch-node-01 --zone=us-central1-a --provisioning-model=SPOT --on-host-maintenance=TERMINATE --service-account=batch-processor@my-project.iam.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.full_control --metadata=startup-script=/scripts/setup.sh
- Dgcloud compute instances create batch-node-01 --zone=us-central1-a --provisioning-model=SPOT --on-host-maintenance=TERMINATE [email protected],storage-full --metadata-from-file=startup-script=/scripts/setup.sh
Cevap
The command specifying `--provisioning-model=SPOT`, `--on-host-maintenance=TERMINATE`, `--service-account=batch-processor@my-project.iam.gserviceaccount.com`, `--scopes=https://www.googleapis.com/auth/devstorage.full_control`, and `--metadata-from-file=startup-script=/scripts/setup.sh` correctly provisions the instance.
The correct option specifies `--provisioning-model=SPOT` combined with `--on-host-maintenance=TERMINATE`, as Spot instances cannot be live-migrated during infrastructure maintenance. It uses `--service-account` to assign the custom IAM service account email and `--scopes` for API permissions. Lastly, it utilizes `--metadata-from-file=startup-script=...` to properly read and upload the local file contents as the VM startup script.
Adım Adım Çözüm
Anahtar Kavram
Deploying Compute Engine instances with custom service accounts, Spot VM availability policies, and startup script file metadata via gcloud CLI.