Rolling update in Managed Instance group (MIG) is the process of gradual update of instances in an instance group to a new instance template. Step By step tutorial with real time example on how to apply configuration updates to the virtual machine in Google Cloud managed instance group.
This is also most important professional cloud architect topic question.
Automatically apply VM configuration updates in a MIG
Google cloud compute engine manages virtual machine configuration in managed instance group using instance template. To learn more about how to set up virtual machines using Instance template refer Create GCP Instance Template In 2 Minutes – Google Cloud Tutorials.
This is Handon’s tutorial, and you can follow along.
Google cloud offers free credits worth 400 $ to learn and explore google cloud platform using free trial account. Learn more on how to create google cloud free trial account Google Cloud Free Credits – Google Cloud Tutorials .
In your browser enter google cloud URL https://console.cloud.google.com/ and log in using your Gmail id.
Search Google Compute engine and navigate to Managed Instance group to check list of all running MIG.
We have already discussed in detailed on steps to create MIG in Google Cloud here Google Cloud Managed Instance Group – Google Cloud Tutorials
Click on Manages instance group which you would like to update.
Click on UPDATE VMS.
Under new template dropdown select the new instance template to update to. Select target size as 100 %.
Under update configuration select Update type as Automatic.
Click UPDATE VM to start the update.
For complex workloads advance update configuration options can be used.
Maximum surge
The max surge configuration in rolling update is used to specify how many additional virtual machines are added to MIG during the time of update.
Maxs surge can be configured using either the number of instances or by using percent value. For example, if the max surge value is set to 10 Instance MIG will use new template to create maximum if 10 virtual machines beyond target size.
Specifying higher value for max surge helps to improve time taken for the update to complete.
The additional VM’s added for the updated process are billed as per google cloud pricing Pricing | Compute Engine: Virtual Machines (VMs) | Google Cloud.
If maxsurge value is not configured than default value is used.
For zonal MIG default max surge is 1 and for regional MIG default value is 3 with 3 zones in a region.
Maximum unavailable instances
The maxUnavailable
option to configure how many instances are unavailable at any time during an automated update.
For example, if maxUnavailable
is set to 2 than maximum of 2 instances are taken offline for the update at a given point of time. This option is more useful for critical workloads where less disruptive update process is required.
maxUnavailable
can be configured either by specifying number of instances or by using the percent configuration.
If maxUnavailable
value is not configured than default value is used.
For zonal MIG default max surge is 1 and for regional MIG default value is 3 with 3 zones in a region.
If you want 0 unavailable instance in your MIG during update process than set maxUnavailable
to 0 and maxSurge
greater than 0.With these settings, Compute Engine removes each old machine only after its replacement new machine is created and running.
The minimum wait time option is used to specify delay for How long to wait after updating an instance before starting to update the next instance.
By default, when you proactively update a MIG, the group deletes your VM instances and swaps them with new instances with new names. If your applications relies on instance name, you can preserver instance name.
check Keep instance names when replacing instances checkbox when updating to new template.
Automatic update supports following actions to update virtual machines.
- only replace
- only restart
- only refresh
- Refresh or restart
- Restart or replace
- Refresh, restart or replace
Depending on type of workload and criticality of update process any one or combination of actions can be configured.
Selective apply VM configuration updates in a MIG
Click on Manages instance group which you would like to update.
Click on UPDATE VMS.
Under new template dropdown select the new instance template to update to. Select the target size of virtual machines to be updated to new instance template.
Only selected number of virtual machines will be updated to new instance template. Remaining virtual machines in MIG continue to run on old instance template.
Under update configuration select update type to selective.
This will Update VMs in this group when they are replaced, refreshed, or restarted, except during auto-healing.
Control the disruption level during selective updates
Depending on type of update it might disrupt the instance state. For an update which requires boot disk to be updated requires replacing the instance. The level of disruption can be configured in selective update.
Minimal action: Use this option to minimized disruption as much as possible or apply a more disruptive action. To minimize disruption set this to NONE.To apply more disruptive action set this action to RESTART or REPLACE. For example, Compute Engine does not need to restart a VM to change its metadata. But if your application reads instance metadata only when a VM is restarted, you can set the minimal action to RESTART
in order to pick up metadata changes.
Most disruptive allowed action: This option is used to prevent an update if you cannot afford the level of disruption. For example, if you set this option to RESTART, and
of you attempt to update a boot disk image than the update fails as it requires more disruptive action of instance recreation than restart.
How do I update my MIG in GCP?
Virtual machines in MIG are updated to new instance templates using rolling updates. New updates can be rolled out to all virtual machine in MIG using automated configuration to specify VM using selective configuration.
How do you automatically apply VM configuration updates in a MIG
To automatically apply VM configuration updates in a MIG select update type to automatic and while specifying new template set target size to 100%.
What is most disruptive allowed action?
This option is used to prevent an update if you cannot afford the level of disruption. For example, if you set this option to RESTART, and
of you attempt to update a boot disk image than the update fails as it requires more disruptive action of instance recreation than restart.