Managed instance group GCE – Static IP not working

google-cloud-platformgoogle-compute-enginestatic-ip

I have a problem with the ip of my instance group.

I have a managed instance group with (autoscaling enabled) on Google Compute Engine and I've setted a static IP on the 1st instance created. After a while (not a specific time) the IP changes and settings goes back to "Temporary ip".

There is a way to set static ip on a managed instance group and stay "safe" from ip change?

EDIT: Or there is a way to prevent the "delete" of the 1st instance created (the instance with the static IP)?

EDIT2: Think i can use a Load balancer setting manage group like backend, but i have a huge problem: I need to grab HTTP and RTMP requests, both from the same backend. I can't understand the correct configuration for this kind of things. Problem is that inside load balancer settings i can set only one backend service.
I need to set the same backend service (the same instance group) for both http and rtmp requests :/

Best Answer

For a managed group with auto-scaling enabled you should design or retrofit your application so that it is independent of specific instance properties that will not persist such as IP address or in-memory data. This is due to the stateless nature of the managed group as described in this document.

In such case, new instances can be created and others recreated following the configured instance template. For example, once utilization ( can be other set metric) decreases it should destroy unused instances and recreates new instance with changed IP addresses. Instances within managed groups are intended to be dynamically re-created, they get created from the instance template. That being said, due to the stateless nature of the managed group with auto-scaling enabled, even though you create instances with static IP it gets change every time with the auto-scaling operation.