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

952 views
Skip to first unread message

Ritik SHUKLA

unread,
Jan 29, 2021, 10:12:03 AM1/29/21
to Google Cloud Developers
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.

pralove

unread,
Jan 29, 2021, 7:29:16 PM1/29/21
to Google Cloud Developers
Looks similar issue is discussed in this stackover flow thread[0].

You can add VMs with specific names to an existing MIG[1].

You can use --base-instance-name[2] flag when creating MIG[3]. VMs will be created with the base instance name you have provided with "-" and random prefix.

You may also create feature request[4] with GCP but there is no ETA of its deliverable. 

Thanks.





Ritik SHUKLA

unread,
Feb 1, 2021, 9:42:37 AM2/1/21
to Google Cloud Developers
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"

Fady (Google Cloud Platform)

unread,
Feb 1, 2021, 8:39:14 PM2/1/21
to Google Cloud Developers

Thank you for the clarification. I believe you meant using stateless managed instance groups as explained in this document. It is currently not possible to modify the naming convention of stateless managed instance groups as it randomizes the suffix when creating new instances from the instance template (Replication happens based on the instance template and not existing instances). 

The only exception is when you manually add an instance with any name as explained earlier by my colleague and per this document. Quoting from the document, “The names that you assign to these managed instances persist if the MIG recreates the VM.” This is in autohealing events and not when autoscaling. If the instance failed a health check, autohealing would recreate it with the same name.

To explain, stateless managed instance groups should not persist data on the instances. Generally they should be used as front-end applications. Meaning that autoscaler would create and destroy instances per configurations while data should persist on a backend database or a storage solution. Usually the group should be behind a load balancer, and the traffic would be directed to the instances without worrying about instance names. This document should explain more about load balancers. 

However, I agree that you may have a good use-case to change the naming convention. As such, I suggest creating a feature request as per this document. Please provide a detailed explanation about the use-case when creating it. This would help the product team prioritize the request accordingly. 

Another workaround and if you do not require an autoscaler, is utilizing unmanaged instance groups. You can manually create any non-identical instances and add them to the group as explained in this document

I hope this helps.


Reply all
Reply to author
Forward
0 new messages