0

Health checks can probe my instance on specific http requests and determine if it is unhealthy.

From the documentation I undertsand that autohealing only works for managed instance group, which means that an instance which is unhealthy will not be restarted but shut down and another instance will be created from the template. So it means statefull data on the disk will be lost.

Is there a way to trigger a instance restart from health checks without using templates (and therefore only rebooting and keeping disk data).

1 Answers1

1

In order to use autoscaling or autohealing with managed instance group your VM needs to be stateless as mentioned here:

Using managed instance groups for stateless applications

Managed instance groups are intended to support stateless applications that aren't dependent on the specific state of the underlying VM instances to run. This allows for features like autoscaling and autohealing, where the managed instance group can delete and recreate instances automatically.

You need to do some research to make your application stateless. For example if you have MySQL database on your VM you can migrate it to CloudSQL. For other data on the disk you can consider taking backup using Google Cloud Storage or host a file server on GCE.

Faizan
  • 1,408
  • 10
  • 17
  • If you are using instance group just for the purpose of load balancing you can create [unmanaged instance](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-unmanaged-instances) group with existing instances and setup a health check with load balancer. – Faizan Feb 28 '17 at 23:41
  • Thanks. If I remember right the health check do not trigger a restart. Another solution I was thinking of is creating a permanent disk which would store the sql files and make a startup script that mount the disk and restart MySQL service on the created instance. Would this work? – Vincent Teyssier Mar 01 '17 at 06:09
  • The health checks for load balancer doesn't trigger VM restart, it just stops sending traffic to that instance until its healthy again. If you are planning to use the same disk with multiple instances in read/write mode that will not work because the disk can be mounted to multiple instances in read only mode. – Faizan Mar 01 '17 at 16:39
  • Thanks. I don't plan on using auto scaling, only auto healing so the external disk should be fine for read/write – Vincent Teyssier Mar 01 '17 at 17:16