1

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.

Grzenio
  • 35,875
  • 47
  • 158
  • 240
hritz220
  • 63
  • 7

1 Answers1

2

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.

Sergiusz
  • 1,175
  • 4
  • 13
  • Hey, thanks for your response but I'm not looking for prefixes to the random string, I'm looking for suffix which should not random i.e there should be a pattern like 001, 002... Example: If the instance group is "my-GCP-group", the instance creation should start with my-GCP-group-001, the second instance should be my-GCP-group-002, my-GCP-group-003, and so on. let's say my-GCP-group-002 is terminated, when the instance group scales out it should create the instance which is missing in the series pattern i.e the new instance created should have a name equals to "my-GCP-group-002". – hritz220 Jan 29 '21 at 16:56