gcloud compute instance-groups managed instance-configs create - create a per-instance config for an instance in a managed instance group
gcloud compute instance-groups managed instance-configs create NAME --instance=INSTANCE [--instance-update-minimal-action=INSTANCE_UPDATE_MINIMAL_ACTION; default="none"] [--stateful-disk=[auto-delete=AUTO-DELETE],[device-name=DEVICE-NAME],[mode=MODE],[source=SOURCE]] [--stateful-metadata=KEY=VALUE,[KEY=VALUE,...]] [--no-update-instance] [--region=REGION | --zone=ZONE] [GCLOUD_WIDE_FLAG ...]
gcloud compute instance-groups managed instance-configs create creates a per-instance config for an instance controlled by a Compute Engine managed instance group. An instance with a per-instance config preserves the specified metadata and/or disks during instance recreation and deletion.
Once created, the config is applied immediately to the corresponding instance, by performing the necessary action (for example, REFRESH), unless overridden by providing the --no-update-instance flag.
To create a per-instance config with a stateful disk my-disk and to add stateful metadata my-key:my-value, on instance my-instance, run:
$ gcloud compute instance-groups managed instance-configs create \ my-group --region=europe-west4 --instance=my-instance \ --stateful-disk=device-name=my-disk,source=projects/my-project/\ zones/us-central1-a/disks/my-disk-3 \ --stateful-metadata="my-key=my-value"
If my-disk did not exist previously in the per-instance config, and if it does not exist in the group's instance template, then the command adds my-disk to my-instance.
- NAME
Name of the managed instance group to create a per-instance config for.
- --instance=INSTANCE
URI/name of an existing instance in the managed instance group.
- --instance-update-minimal-action=INSTANCE_UPDATE_MINIMAL_ACTION; default="none"
Perform at least this action on the instance while updating, if --update-instance is set to true. INSTANCE_UPDATE_MINIMAL_ACTION must be one of:
- none
No action
- refresh
Apply the new configuration without stopping VMs, if possible. For example, use ``refresh`` to apply changes that only affect metadata or additional disks.
- restart
Apply the new configuration without replacing VMs, if possible. For example, stopping VMs and starting them again is sufficient to apply changes to machine type.
- replace
Replace old VMs according to the --replacement-method flag.
- --stateful-disk=[auto-delete=AUTO-DELETE],[device-name=DEVICE-NAME],[mode=MODE],[source=SOURCE]
Disks considered stateful by the instance group. Managed instance groups preserve and reattach stateful disks on VM autohealing, update, and recreate events.
You can also attach and preserve disks, not defined in the group's instance template, to a given instance.
The same disk can be attached to more than one instance but only in read-only mode.
Use this argument multiple times to attach and preserve multiple disks.
- device-name
Name under which disk is or will be attached.
- source
Optional argument used to specify the URI of an existing persistent disk to attach under specified device-name.
- mode
Specifies the mode of the disk to attach. Supported options are ro for read-only and rw for read-write. If omitted when source is specified, rw is used as a default. mode can only be specified if source is given.
- auto-delete
(Optional) Specifies the auto deletion policy of the stateful disk. The following options are available:
never: (Default) Never delete this disk. Instead, detach the disk when its instance is deleted.
on-permanent-instance-deletion: Delete the stateful disk when the instance that it's attached to is permanently deleted from the group; for example, when the instance is deleted manually or when the group size is decreased.
- --stateful-metadata=KEY=VALUE,[KEY=VALUE,...]
Additional metadata to be made available to the guest operating system in addition to the metadata defined in the instance template.
Stateful metadata may be used to define a key/value pair specific for the one given instance to differentiate it from the other instances in the managed instance group.
Stateful metadata key/value pairs are preserved on instance recreation, autohealing, updates, and any other lifecycle transitions of the instance.
Stateful metadata have priority over the metadata defined in the instance template. This means that stateful metadata that is defined for a key that already exists in the instance template overrides the instance template value.
Each metadata entry is a key/value pair separated by an equals sign. Metadata keys must be unique and less than 128 bytes in length. Multiple entries can be passed to this flag, e.g., --stateful-metadata key-1=value-1,key-2=value-2,key-3=value-3.
- --update-instance
Apply the configuration changes immediately to the instance. If you disable this flag, the managed instance group will apply the configuration update when you next recreate or update the instance.
Example: say you have an instance with a disk attached to it and you created a stateful configuration for the disk. If you decide to delete the stateful configuration for the disk and you provide this flag, the group immediately refreshes the instance and removes the stateful configuration for the disk. Similarly if you have attached a new disk or changed its definition, with this flag the group immediately refreshes the instance with the new configuration.
Enabled by default, use --no-update-instance to disable.
- At most one of these can be specified:
- --region=REGION
Region of the managed instance group to create a per-instance config for. If not specified, you might be prompted to select a region (interactive mode only).
A list of regions can be fetched by running:
$ gcloud compute regions list
Overrides the default compute/region property value for this command invocation.
- --zone=ZONE
Zone of the managed instance group to create a per-instance config for. If not specified, you might be prompted to select a zone (interactive mode only).
A list of zones can be fetched by running:
$ gcloud compute zones list
Overrides the default compute/zone property value for this command invocation.
These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.
Run $ gcloud help for details.
These variants are also available:
$ gcloud alpha compute instance-groups managed instance-configs \ create
$ gcloud beta compute instance-groups managed instance-configs create