Question

Difficulty: MediumDeploying and Managing Compute Engine Virtual Machines

A cloud engineer needs to deploy a high-availability Compute Engine instance named `web-prod-01` in zone `us-central1-a` using the `gcloud` CLI. The application hosted on this instance cannot tolerate unexpected downtime during host infrastructure updates, so the virtual machine must be migrated to another host during maintenance events rather than shut down. Additionally, if the host hardware experiences a failure, the instance must automatically restart. Which `gcloud compute instances create` command should the engineer execute to meet these requirements?

  1. gcloud compute instances create web-prod-01 --zone=us-central1-a --on-host-maintenance=MIGRATE --automatic-restartAnswer
  2. B
    gcloud compute instances create web-prod-01 --zone=us-central1-a --maintenance-policy=LIVE_MIGRATE --auto-restart=true
  3. C
    gcloud compute instances create web-prod-01 --zone=us-central1-a --provisioning-model=SPOT --on-host-maintenance=MIGRATE
  4. D
    gcloud compute instances create web-prod-01 --zone=us-central1-a --on-host-maintenance=TERMINATE --no-automatic-restart

Answer

The correct command is `gcloud compute instances create web-prod-01 --zone=us-central1-a --on-host-maintenance=MIGRATE --automatic-restart`.
The command containing `--on-host-maintenance=MIGRATE` and `--automatic-restart` correctly applies the standard Compute Engine availability policy flags for live migration during maintenance and automated restart after hardware failure.

Step-by-Step Solution

1
Identify the availability requirements for host maintenance.
Live migration requires setting the host maintenance policy to `MIGRATE`.
Compute Engine allows instances to be live-migrated to another host in the background without shutting down.
2
Identify the flag for handling hardware crash recovery.
Automatic restart requires setting the boolean flag `--automatic-restart`.
If host hardware fails, this setting instructs GCP to restart the instance automatically.
3
Verify correct gcloud CLI syntax.
The valid syntax uses `--on-host-maintenance=MIGRATE` and `--automatic-restart`.
Flags like `--maintenance-policy` or `--auto-restart` are invalid flag syntax in the gcloud SDK.

Key Concept

Compute Engine Instance Scheduling & Availability Policies
Estimated Time:1m 30s
Rate this question