A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/compute/docs/instance-groups/how-stateful-migs-work below:

How stateful MIGs work | Compute Engine Documentation

A stateful managed instance group (stateful MIG) preserves the unique state of each virtual machine (VM) instance—including VM name, attached persistent disks, IP addresses, and/or metadata—on machine restart, recreation, auto-healing, or update.

This page describes how stateful MIGs work. See Configuring stateful MIGs to learn how to set up a stateful MIG.

Overview of how stateful MIGs work

A MIG is considered stateful if you have created a stateful configuration.

You create a stateful configuration by setting a non-empty stateful policy and/or one or more non-empty per-instance configurations:

The configuration is effective after you or the MIG applies it:

After the stateful configuration (stateful policy and/or per-instance configurations) is applied, you can verify it by inspecting the preserved state of each managed instance.

Subsequent changes to your MIG's stateful configuration or size (for example, decreasing the MIG's size, or deleting or abandoning instances from the MIG) can affect the preserved states of the instances.

How stateful configuration is applied to managed instances

Your stateful configuration is effective after you or the MIG applies it. Applying stateful configuration to a MIG's instances depends on the configuration:

How stateful policy updates are applied to instances

When you create or update a stateful policy, for example add or remove a stateful disk, the MIG applies your stateful policy configuration to all managed instances in the group automatically and asynchronously. A MIG also automatically applies your stateful policy configuration to new instances during their creation, for example, when a MIG's size is increased or when you create instances in the MIG manually.

After the configuration is applied, you can see the effect of the update in each managed instance's preserved state from policy.

Updates to a stateful policy do not disrupt running VMs.

When you update a stateful policy to add a stateful disk, the MIG updates each VM resource, changing the value of the disk's autoDelete flag (instances.disks[].autoDelete):

Changing the value of the autoDelete flag does not disrupt a running VM.

How per-instance configuration updates are applied to instances

When you create or update a per-instance configuration, you can choose whether to apply the new configuration manually or automatically. For more information, see Applying stateful configuration from per-instance configurations.

The following table shows the disruption levels that are required to apply different per-instance configuration updates to a VM:

Per-instance configuration update Disruption to VM required for applying Configure a disk, defined by the instance template, to be stateful (added to the per-instance configuration) REFRESH Configure a disk, defined by the instance template, to be stateless (removed from the per-instance configuration) REFRESH Add a disk, not defined by the instance template, and attach it to the VM REFRESH Remove a disk, not defined by the instance template, and detach it from the VM REFRESH Add a metadata key-value pair REFRESH Remove a metadata key-value pair REFRESH Add an external boot disk, not created from the instance template, and attach it to the VM REPLACE Remove an external boot disk, not created from the instance template, detach it from the VM, and create a boot disk from the instance template instead REPLACE Set an internal IP address REPLACE Remove an internal IP address REPLACE

When applying an updated per-instance configuration to the corresponding VM, the MIG performs the following actions depending on which stateful items are updated:

After a per-instance configuration is applied to a corresponding managed VM, you can see the effect of the update in the instance's preserved state from configuration.

Preserved state of a managed instance

When it is applied, the MIG translates your instance template and stateful configuration into a "preserved state" for each managed instance.

You can view the preserved state by inspecting a managed instance.

The MIG maintains these preserved states automatically, and the MIG automatically and asynchronously applies this state to each corresponding actual VM instance in the MIG.

The preserved state describes which individual items (persistent disks, IP addresses, metadata) are stateful for a given instance:

The preserved state generated based on a stateful policy is stored separately from the preserved state generated based on a per-instance configuration. The MIG combines both of them when recreating a VM, with the preserved state from a per-instance configuration taking priority.

Preserved state according to stateful policy

A stateful policy specifies items, present in all instances and defined in the MIG's instance template, to preserve individually for each VM instance in a MIG.

When applied, the MIG translates the stateful policy into instance-specific preserved states (managedInstances[].preservedStateFromPolicy). The MIG maintains these preserved states automatically.

The following example shows a MIG with two VM instances that use a stateful disk defined in a stateful policy that applies to every instance. There are no per-instance configurations in this example.

The preceding figure shows a MIG with two instances:

Preserved state according to per-instance configuration

A per-instance configuration specifies items that must be preserved for a particular VM. These items don't have to be defined in the MIG's instance template.

When applied, the MIG translates each per-instance configuration into a preserved state (preservedStateFromConfig) for the corresponding instance.

The following example shows a MIG with two VM instances for which stateful metadata and disks are defined in per-instance configurations (PICs) for every instance. There is no stateful policy in this example.

In the preceding figure:

Note that the disks and metadata in the preserved state from per-instance configurations are not defined by the instance template in this example; instead, they are defined by the per-instance configurations only. This is because the configuration that you specify in a per-instance configuration is specific for a particular VM, which means it does not have to be present in the instance template.

Per-instance configurations have priority over stateful policy and instance template

You can configure both a stateful policy and one or more per-instance configurations in one MIG. For example, in a stateful policy, you can define stateful disks that are present in all instances, and in per-instance configurations, you can define instance-specific metadata.

A managed instance's per-instance configuration takes priority over conflicting configuration in the instance template or in a stateful policy.

If you apply a per-instance configuration to add a disk or a network interface that is already defined in a stateful policy, the MIG stores the stateful configuration for that disk or network interface in the managed instance's preserved state from per-instance configuration (preservedStateFromConfig) and removes the conflicting entries from its preserved state from policy (preservedStateFromPolicy). The MIG must refresh the VM if the new preserved state is different from the previous one. The refresh could result in metadata change, external IP address change, or a disk swap to detach the disk from the last preserved state configuration and attach the disk specified in the new preserved state configuration.

In the following example, the per-instance configuration for VM instance node-1 redefines:

In the preceding figure:

How removing a resource from a stateful policy affects preserved state

If you remove a resource configuration from your stateful policy, the MIG automatically removes the corresponding preservedStateFromPolicy for all managed instances. The compute resources remain attached to the instances, but they are no longer stateful.

In the following example, removing a disk from the stateful policy leads to removal of that disk from preserved states from policy in all managed VMs. Those disks remain attached to their VMs, but they are no longer stateful and might be deleted and recreated on next VM recreation.

If the same item, for example, a stateful persistent disk, is present both in the stateful policy and a per-instance configuration, and you remove its stateful configuration from the stateful policy only, the MIG doesn't remove it from the per-instance configuration. For the corresponding VM, the configured resource remains stateful.

In the following example, removing the disk from the stateful policy does not lead to removal of the disk from the per instance configuration. The disk remains stateful because it is still a part of preserved state from configuration.

How removing items from per-instance configurations affects preserved state

If you remove the stateful configuration from a per-instance configuration, and apply the change, the MIG automatically removes the stateful configuration from the preserved state from configuration (preservedStateFromConfig) in the corresponding managed instance. The compute resources that are no longer part of any preserved state become stateless.

How removing stateful disks configuration from per-instance configurations affects preserved state

If you remove a stateful disk from a per-instance configuration and apply the change to the associated VM instance, the MIG does the following:

In the following example, removing a blue and a green disk from node-1's per-instance configuration leads to removal of both disks from the node-1 managed instance's preserved state from configuration.

How removing stateful metadata from per-instance configurations affects preserved state

Removing stateful metadata from a per-instance configuration and applying the change causes the MIG to immediately remove that stateful metadata from the corresponding managed instance's preserved state:

In the following example, removing mode:dev and id:xyz273 metadata from node-1's per-instance configuration leads to automatic removal of both key-value pairs from the node-1 managed instance's preserved state from configuration.

How removing stateful IP configuration from per-instance configurations affects preserved state

Removing the internal IP configuration from per-instance configuration makes the IP address for this VM stateless. No automated changes are performed on this VM, but the IP address can change after the VM is recreated, updated, or autohealed.

Fallback to stateful policy

If you remove the stateful configuration of a resource from a per-instance configuration, and you configured the same resource in the stateful policy, then the resource remains stateful according to the stateful policy.

The MIG automatically removes the item's stateful configuration from the preservedStateFromConfig and adds it to the preservedStateFromPolicy for the corresponding managed instance.

In the following example, removing a disk from node-1's per-instance configuration does not lead to removal of the disk from the stateful policy. The disk remains stateful according to the stateful policy:

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4