Soru

Zorluk: OrtaManaging Compute Engine Resources

A cloud engineering team needs to standardize a base environment for auto-scaling a web application currently running on a standalone Compute Engine instance. The team plans to capture the configuration of the existing instance's boot disk, package it into a custom image, and use that image to generate an instance template for a new Managed Instance Group (MIG). In what sequential order should the engineer perform these gcloud CLI operations to ensure data consistency and proper resource dependency?

  1. 1Stop the source Compute Engine virtual machine instance using `gcloud compute instances stop`.
  2. 2Create a snapshot of the VM's boot disk using `gcloud compute disks snapshot`.
  3. 3Create a custom image from the persistent disk snapshot using `gcloud compute images create`.
  4. 4Create a new instance template specifying the custom image using `gcloud compute instance-templates create`.

Cevap

The correct execution sequence is: 1) Stop the source Compute Engine instance to flush disk caches and guarantee data consistency. 2) Create a persistent disk snapshot from the stopped VM's boot disk. 3) Create a custom image with the snapshot specified as its source. 4) Create an instance template referencing the newly created custom image.
The correct order follows dependency and data-integrity requirements: stopping the VM ensures disk consistency, creating a disk snapshot captures that state, building a custom image from the snapshot provides a reusable boot resource, and defining the instance template uses the finished custom image.

Adım Adım Çözüm

1
Halt file system writes on the source virtual machine.
The VM enters the TERMINATED state, ensuring disk integrity.
Creating snapshots from a running instance without stopping it or unmounting the file system can lead to crash-inconsistent snapshots.
2
Execute `gcloud compute disks snapshot` against the instance boot disk.
A consistent persistent disk snapshot resource is created.
Snapshots store point-in-time data required to build portable, versioned images.
3
Execute `gcloud compute images create` pointing to the snapshot as the source.
A custom image resource is added to the project's image family/catalog.
Instance templates require a boot image reference, which is constructed from the snapshot asset.
4
Execute `gcloud compute instance-templates create` with the `--image` flag set to the custom image.
An instance template is established for deployment into Managed Instance Groups.
Instance templates are immutable specifications that require all underlying image dependencies to already exist.

Anahtar Kavram

Compute Engine Image and Template Lifecycle Management
Bu soruyu puanla