This document explains how to create a regional or zonal managed instance group (MIG) from an existing virtual machine (VM) instance.
By creating a MIG, you can scale the service running on a single VM across multiple VMs and manage them as a single entity. MIGs are useful to make your workloads highly available and scalable. For more information, see the benefits of using a MIG.
Before you begin
- If you haven't already, create and start a VM.
Limitations
The following limitations apply when you create a MIG from an existing VM:
The MIG doesn't add the existing VM to the MIG. The VM continues to exist as a standalone VM.
You can't create stateful MIGs from an existing VM.
Create a MIG from an existing VM
You can create a MIG from an existing VM that is running, stopped, or suspended. Creating a MIG from an existing VM involves the configuration of the following:
An instance template, which Compute Engine uses to define the properties of the VMs in the MIG. By default, the instance template specifies the following:
The same properties of the existing VM, except for the existing VM's IP addresses.
An option to create a custom boot disk image from the existing VM's boot disk. Additionally, if the existing VM uses non-boot disks, Compute Engine does the following as applicable:
For any local SSD that is attached to the existing VM, Compute Engine creates a blank local SSD disk.
For any persistent disk in read-write mode that is attached to the existing VM, Compute Engine creates a custom persistent disk image from the existing VM's persistent disk image.
For any persistent disk in read-only mode that is attached to the existing VM, the same disk is included in the instance template.
Optionally, you can customize the disks and properties of the instance template.
The MIG, which uses the instance template you configured in the previous step. By default, the MIG is a zonal MIG that specifies the following:
Autoscaling is disabled.
One VM in the group.
The same zone where the existing VM is located.
Optionally, you can customize the properties of the MIG.
To create a MIG from an existing VM, follow these steps:
In the Google Cloud console, go to the VM instances page.
Select the VM that you want to use to create the MIG.
Click Create a group based on this VM.
The Scale to instance group page opens.
In the Instance template properties section, do the following:
In the Name field, use the default name or enter a name for the instance template.
In the Disks section, do the following:
Boot disk: By default, Compute Engine generates a new custom image of the VM boot disk. If you want to use an existing disk instead, click
Edit boot disk. You can select a public image or an existing custom image to attach to the VMs in the MIG.Existing disk: Applicable only if your VM has a read-only disk. Optionally, you can do one of the following:
To customize any attachment settings of the read-only disk, click
Edit disk.To remove the disk, click
Remove disk.
New disk: Applicable only if your VM has a read-write disk. By default, Compute Engine creates a new custom disk image. Optionally, you can do one of the following:
To use an existing disk or modify the disk settings, click
Edit disk.To remove the disk, click
Remove disk.
If the existing VM is running or suspended, and you have specified to attach new boot or non-boot disks that use the VM's disk images as sources, the On image generation section appears. Then, you must select one of following options:
If you want to maintain the file system's integrity while generating an image from the VM disk, stop the VM by selecting Stop the VM. You can restart the VM after the MIG is created. Until then, your service is interrupted.
If you do not want interruption to your service and the file system's integrity is not a concern, select Keep the VM running.
To further customize the instance template used to define the properties of the VMs in the MIG, click Create instance templates.
Customize instance template and modify the fields as needed. For more information, see
In the Instance group properties section, do the following:
In the Name field, use the default name or enter a name for the MIG.
In the Location section, you can choose to create a regional or zonal MIG by doing one of the following:
To create a regional MIG, follow these steps:
Select Multiple zones.
In the Region list, select a region where to create the VMs in the MIG.
In the Zones list, select the zones where to create the VMs in the MIG.
To create a zonal MIG, follow these steps:
Select Single zone (default).
In the Region list, select a region where to create the VMs in the MIG. By default, the region where the original VM exists is selected.
In the Zone list, select a zone where to create the VMs for the MIG. By default, the zone where the original VM exists is selected.
To further specify the MIG settings—for example, to specify the number of VMs—click regional or zonal MIG.
Configure instance group. For more information, see how to create a
After you've finished customizing the instance template and the MIG, click Create group. If your VM is running and you specified to stop the VM in the previous steps, click Stop VM and create group.
The Instance groups page opens. Creating the instance template and the MIG might take a few minutes to complete.
What's next
Learn how to update VM configurations in a MIG.
Learn how to autoscale groups of VMs.
Learn more about different configuration options available in a MIG.
Learn more about building scalable and resilient web applications.
Learn more about disaster recovery on Google Cloud.