Question

Difficulty: MediumDeploying and Managing Compute Engine Virtual Machines

A system administrator needs to deploy a standard Compute Engine virtual machine instance named `analytics-db` in zone `us-central1-a` using the Google Cloud CLI. Due to third-party database software licensing rules tied to physical CPU sockets, the VM must be configured to terminate (stop) rather than live-migrate whenever Google performs host maintenance. Additionally, the instance must automatically restart if it crashes or if the host hardware fails unexpectedly. Which command should the administrator run to fulfill these requirements?

  1. gcloud compute instances create analytics-db --zone=us-central1-a --on-host-maintenance=TERMINATE --automatic-restartAnswer
  2. B
    gcloud compute instances create analytics-db --zone=us-central1-a --on-host-maintenance=MIGRATE --no-automatic-restart
  3. C
    gcloud compute instances create analytics-db --zone=us-central1-a --provisioning-model=SPOT --on-host-maintenance=TERMINATE
  4. D
    gcloud compute instances create analytics-db --zone=us-central1-a --maintenance-policy=TERMINATE --restart-on-failure

Answer

Execute `gcloud compute instances create analytics-db --zone=us-central1-a --on-host-maintenance=TERMINATE --automatic-restart` to configure the instance to stop on maintenance events while allowing automatic restarts during unexpected host crashes.
The command containing `--on-host-maintenance=TERMINATE` and `--automatic-restart` accurately sets the scheduling policy to stop the instance during scheduled maintenance while enabling Compute Engine to restart the VM automatically if the host system crashes.

Step-by-Step Solution

1
Identify host maintenance requirement
The requirement specifies terminating the instance instead of live migrating, which maps to `--on-host-maintenance=TERMINATE`.
By default, standard GCP VMs live-migrate (`MIGRATE`). Software licensing constraints often require shutting down (`TERMINATE`) during maintenance.
2
Identify recovery behavior requirement
The VM must restart if hardware fails, which requires `--automatic-restart`.
The `--automatic-restart` flag tells Compute Engine to restart the VM if it crashes or the physical host experiences an unrecoverable failure.
3
Select correct gcloud flag syntax
Combine `--on-host-maintenance=TERMINATE` and `--automatic-restart` in the `gcloud compute instances create` command.
These are the exact gcloud CLI flags for managing Compute Engine instance scheduling behavior.

Key Concept

Compute Engine Instance Scheduling Options and Maintenance Policies
Estimated Time:1m 15s
Rate this question