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?
- 1Stop the running VM instance using `gcloud compute instances stop app-server-1`.
- 2Modify the machine type configuration using `gcloud compute instances set-machine-type app-server-1 --machine-type=e2-standard-4`.
- 3Provision the new persistent disk using `gcloud compute disks create log-disk-1`.
- 4Attach the new persistent disk using `gcloud compute instances attach-disk app-server-1 --disk=log-disk-1`.
- 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
Key Concept
Managing Compute Engine VM Instance Lifecycle and Disk Operations via gcloud CLI
Estimated Time:1m 30s