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:
- Setting and preserving instance names
- Configuring and managing stateful persistent disks
- Configuring and managing stateful metadata
Before you begin
- If you want to use the command-line examples in this guide:
- If you want to use the API examples in this guide, set up API access.
- Review When to use stateful MIGs
- Review What makes a MIG stateful
- For more information, see How stateful MIGs work
Stateful MIGs have the following limitations:
- You cannot use autoscaling with stateful MIGs.
- When you permanently delete an instance (either manually or by resizing), the MIG does not preserve the instance's stateful metadata.
- For rolling updates, you must set the
- 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
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
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.
We want to learn about your use cases, challenges, and feedback about stateful MIGs. Please share your feedback with our team at firstname.lastname@example.org.