An infrastructure team is provisioning Compute Engine instances using the gcloud command-line tool. The workload consists of stateless batch processing tasks running on Spot VMs, and each VM requires execution of a local shell script during boot. Which TWO gcloud configuration practices are correct for this scenario?
- Set `--on-host-maintenance=TERMINATE` for the Spot VM instances because they do not support live migration.Answer
- Use `--metadata-from-file=startup-script=path/to/script.sh` to supply a startup script from a file on the local machine.Answer
- CConfigure `--provisioning-model=SPOT` for stateful production web server instances to guarantee continuous availability at discounted rates.
- DUse `--metadata=startup-script=path/to/script.sh` to load and run a startup script stored on the local file system.
Answer
The two correct choices are to set the host maintenance policy to terminate for Spot VMs (`--on-host-maintenance=TERMINATE`) and to use `--metadata-from-file=startup-script=path/to/script.sh` to read and pass a local startup script.
Spot instances do not support live migration during host maintenance events and require setting the maintenance policy to terminate. Additionally, supplying a startup script located on the local filesystem requires using `--metadata-from-file` so gcloud reads the contents of the file before sending the request to the Compute Engine API.
Step-by-Step Solution
Key Concept
Compute Engine instance deployment flags, Spot VM maintenance policies, and metadata configuration via gcloud CLI.
Estimated Time:1m 30s