This solution and sample code shows how to use Consul, a DNS-based service-discovery product, as part of an HAProxy-based, internal load-balancing system on Google Cloud Platform.
The complete article and instructions for using the code in this repository are at https://cloud.google.com/solutions/autoscaled-load-balancing-using-haproxy-and-consul-on-compute-engine.