Configuring stateful MIGs

You can improve the uptime and resiliency of your stateful applications with stateful managed instance groups (stateful MIGs).

By creating a stateful configuration, you can preserve the unique state of each of your MIG's Virtual Machine (VM) instances—including name, persistent disks, and metadata—on machine restart, recreation, auto-healing, or update events.

This page describes ways you can configure stateful MIGs, along with links to the guides for each task:

After you create or update a stateful configuration, you can apply it to make it effective, view the config as well as the effective preserved state of each VM, or remove it if you no longer need it.

Before you begin

Limitations

Stateful MIGs have the following limitations:

  • You cannot use autoscaling with stateful MIGs.
  • You cannot use proactive rolling updates if you configure stateful disks or stateful metadata.
    • You can control updates and limit disruption by updating specific instances instead.
    • If you use custom instance names and don't configure stateful disks or metadata, you can use proactive updates, but, to preserve instance names, you must set the replacement method to RECREATE.
  • When you permanently delete an instance (either manually or by resizing), the MIG does not preserve the instance's stateful metadata.
  • For stateful regional MIGs, you must disable proactive redistribution (set the redistribution type to NONE) to prevent deletion of stateful instances by automatic cross-zone redistribution.

Setting and preserving instance names

A MIG always preserves the names of its VM instances, unless you permanently delete the instances by decreasing the group size or by performing a rolling update that substitutes existing instances with new ones.

If you want to preserve instance names during updates, set the replacement method for the update to RECREATE in the group's update policy.

You can specify custom names by creating instances manually or you can let the MIG autogenerate names for its VMs.

Setting custom VM names is useful for:

  • Migrating existing standalone VMs to a stateful MIG to benefit from autohealing and auto-updating, while preserving their names.
  • Deploying architectures where external dependencies rely on specific VM names, for example, a master that keeps a registry of working nodes based on pre-configured names or using a special naming pattern.
  • Deploying legacy configurations that require specific VM names, for example, because the names are hardcoded.

In all other cases, you can let the MIG autogenerate VM names using the base instance name plus a random suffix.

Configuring and managing stateful persistent disks

Configuring persistent disks to be stateful lets you benefit from VM autohealing and controlled updates while preserving the state of the disks. For more information, see the use cases for stateful MIGs.

For instructions, see Configuring stateful persistent disks.

Configuring stateful metadata

You can use instance metadata to set properties for and communicate with your applications through the metadata server. For example, you can use metadata to configure the identity of the VM, environment variables, information about cluster architecture, or data range this VM is responsible for.

By using stateful metadata you ensure that instance-specific metadata is preserved on instance autohealing, update, and recreate events.

For instructions, see Configuring stateful metadata.

Applying, viewing, and removing stateful metadata

After you configure a MIG to be stateful, you can:

  • Apply the stateful config for it to take effect.
  • View the stateful config as well as the effective preserved state of your managed instances.
  • Remove the stateful config.

For instructions, see Applying, viewing, and removing stateful configuration.

Feedback

We want to learn about your use cases, challenges, and feedback about stateful MIGs. Please share your feedback with our team at mig-discuss@google.com.

What's next