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
After you create or update a stateful configuration, you can apply it to make it effective, view the configuration as well as the effective preserved state of each VM, or remove it if you no longer need it.
Before you begin
- If you want to use the command-line examples in this guide, do the following:
- 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:
- A stateful MIG does not preserve instance IP addresses on instance recreation, autohealing, or update operations.
- A regional stateful MIG does not automatically orchestrate cross-zone
- When using a regional MIG, you can make your stateful application resilient to zonal failure by deploying redundant replicas to multiple zones and relying on your application's data replication functionality.
- You cannot stop or suspend VM instances in a stateful MIG.
- You cannot use autoscaling with a stateful MIG.
- If you want to use automated rolling updates, you must set the
- When you permanently delete an instance (either manually or by resizing), the MIG does not preserve the instance's stateful metadata.
- For a regional stateful MIG, 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 primary VM 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 configuration for it to take effect.
- View the stateful configuration as well as the effective preserved state of your managed instances.
- Remove the stateful configuration.
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.
- Create VMs with specific names in a MIG.
- Configure stateful persistent disks for all VMs or for specific VMs in a MIG.
- Configure stateful metadata for VMs in a MIG.
- Apply, view, or remove your stateful configuration.
- Learn more about about MIGs and working with managed instances.