In google cloud platform, can we name the instances in a specific series in instance group?

1.1k Views Asked by At

I'm new to the google cloud platform, I've created an instance group. I want to know that, Is it possible to name the instances of instance group in a specific series?

For eg. :

my-GCP-instance-001,
my-GCP-instance-002,
my-GCP-instance-003

then if a new instance is created it should acquire the name

my-GCP-instance-004

let's say instance group scales in (kills an instance), let's assume it terminates

my-GCP-instance-002

when it scales out and creates a new instance it should identify the missing series

my-GCP-instance-002

and name its instance

my-GCP-instance-002.

Let me know if it is possible, it will be very helpful.

1

There are 1 best solutions below

1
On

When creating an instance group, you can supply the --base-instance-name flag. Each VM in that instance group will be assigned a random string as part of its name. The base name is prepended to this random string. For example, if you set the base name to my-GCP-instance-, VMs will have names like my-GCP-instance-yahs and my-GCP-instance-qtyz.

You can also take a look at Working with managed instances:

If you have a system that depends on specific names, use the gcloud tool or API to add VMs with specific names to an existing MIG.
The names that you assign to these managed instances persist if the MIG recreates the VM. For more information about preserving the state of MIG instances, see stateful MIGs.