Question

Difficulty: MediumManaging Compute Engine Resources

An administrator needs to perform scheduled offline maintenance on a standalone Compute Engine instance named `app-server-1`. The administrator must upgrade its machine type to `e2-standard-4` and attach a newly provisioned persistent disk named `log-disk-1` for additional log storage using the `gcloud` CLI. What is the correct sequence of steps to perform this maintenance operation?

  1. 1Stop the running VM instance using `gcloud compute instances stop app-server-1`.
  2. 2Modify the machine type configuration using `gcloud compute instances set-machine-type app-server-1 --machine-type=e2-standard-4`.
  3. 3Provision the new persistent disk using `gcloud compute disks create log-disk-1`.
  4. 4Attach the new persistent disk using `gcloud compute instances attach-disk app-server-1 --disk=log-disk-1`.
  5. 5Start the VM instance using `gcloud compute instances start app-server-1`.

Answer

The correct sequence is: 1) Stop the VM instance (`gcloud compute instances stop`), 2) Update the machine type (`gcloud compute instances set-machine-type`), 3) Create the persistent disk (`gcloud compute disks create`), 4) Attach the persistent disk (`gcloud compute instances attach-disk`), and 5) Start the VM instance (`gcloud compute instances start`).
Changing a Compute Engine VM instance's machine type requires the instance to be in the STOPPED/TERMINATED state. Therefore, stopping the VM is the mandatory first step. Once stopped, the machine type is reconfigured. Next, creating the persistent disk resource must occur before attaching it to the instance. Finally, attaching the disk and starting the VM instance completes the maintenance workflow cleanly.

Step-by-Step Solution

1
Stop the VM instance.
The VM enters the TERMINATED state, releasing hardware resources and allowing hardware property changes like machine type.
Machine types cannot be modified on running Compute Engine instances.
2
Execute gcloud compute instances set-machine-type.
The VM configuration is updated to e2-standard-4.
Reconfiguring instance specs must occur while the VM is stopped.
3
Create the persistent disk resource.
The persistent disk log-disk-1 is created in the target zone.
The disk must exist in GCP before it can be attached to an instance.
4
Attach the disk using gcloud compute instances attach-disk.
The disk log-disk-1 is mapped to app-server-1.
The disk attachment must be configured before launching the application workload.
5
Start the VM instance.
The instance boots up with 4 vCPUs and the secondary persistent disk attached.
Brings the application back online following maintenance.

Key Concept

Managing Compute Engine VM Instance Lifecycle and Disk Operations via gcloud CLI
Estimated Time:1m 30s
Rate this question