2

I'm implementing IaC for a web application consisting of monoliths and microservices. I want to place an internal HTTP load balancer in front of all our microservices and have not found any example for that yet. I looked at Cloud Foundation Toolkit. The Internal Load Balancer here supports only TCP / UDP Internal LoadBalancer. Google's deploymentmanager-samples has no mention of it at all!! At this moment, it seems like the only option is to build the python template from scratch.

Before I jump into that rabbit hole, wanted check if any working sample or example is available on this.

smaikap
  • 474
  • 1
  • 7
  • 19

1 Answers1

5

According to some Google document, You just need to modify some values in the internal TCP LB template.

Below is regionBackendService of internal TCP LB sample code.

{
      'name': loadbalancer_name,
      'type': 'compute.v1.regionBackendService',
      'properties': {
          'region': properties['region'],
          'network': properties['network'],
          'healthChecks': ['$(ref.' + healthcheck_name + '.selfLink)'],
          'backends': properties['instance-groups'],
          'protocol': 'TCP',
          'loadBalancingScheme': 'INTERNAL',
      }
  }

And this is compute.v1.regionBackendService reference at Google document.

protocol

Possible values are HTTP, HTTPS, HTTP2, TCP, SSL, UDP or GRPC. depending on the chosen load balancer or Traffic Director configuration. Refer to the documentation for the load balancer or for Traffic Director for more information.

loadBalancingScheme

Choose INTERNAL_MANAGED for Internal HTTP(S) Load Balancing.

So you need to modify 'protocol':'TCP' to 'protocol':'HTTP' or HTTPS, and 'loadBalancingScheme': 'INTERNAL' to 'loadBalancingScheme': 'INTERNAL_MANAGED'.

Below is forwardingRule of TCP intenal LB code.

{
      'name': forwardingrule_name,
      'type': 'compute.v1.forwardingRule',
      'properties': {
          'ports': [80],
          'network': properties['network'],
          'subnetwork': properties['subnet'],
          'region': properties['region'],
          'backendService': '$(ref.' + loadbalancer_name + '.selfLink)',
          'loadBalancingScheme': 'INTERNAL',
      }
  }

And you can find reference about this resource too.

loadBalancingScheme

INTERNAL_MANAGED is used for: Internal HTTP(S) Load Balancing

IPProtocol

Internal HTTP(S) Load Balancing: The load balancing scheme is INTERNAL_MANAGED, and only TCP is valid.

As a result, You need to modify loadBalancingScheme value from INTERNAL to INTERNAL_MANAGED. Or you maybe need to add the IPProtocol value to your forwardingrule.

Lastly, below is healthcheck of TCP internal LB code.

{
      'name': healthcheck_name,
      'type': 'compute.v1.healthCheck',
      'properties': {
          'type': 'TCP',
          'tcpHealthCheck': {
              'port': 80
          },
      }
  }

As i found in document, You must use a 'regionhealthcheck' instead 'healthcheck' for http(s) internal LB .

So you need to modify resource type to compute.v1.regionHealthChecks

I'm not completely sure for my description, but you can create your own HTTP(S) internal LB enough through referring to the Google documentation and sample code.

SeungwooLee
  • 959
  • 3
  • 12
  • Please click check botton to accept my answer if it was helpful enough :) – SeungwooLee Jan 12 '21 at 06:02
  • I'll test this first :) – smaikap Jan 12 '21 at 06:51
  • 1
    hey, also check this documentation, may be of your interest :) https://cloud.google.com/load-balancing/docs/l7-internal/monitoring – BraveAdmin Jan 13 '21 at 11:57
  • Forgot to update here, but I made it work. In reality, it is closer to External HTTP LB than an Internal TCP LB. I had to use all regional resources instead of the non-regional ones. 2 extra requirements are: the regionalTargetHTTPProxy requires a proxy only subnet and a firewall rule to allow traffic from the proxy only subnet to the internal network where the MIGs are running. – smaikap Mar 24 '21 at 02:42
  • Right now it is a config only deployment. I'm planning to convert it into a template and add it back to cloudfoundry. – smaikap Mar 24 '21 at 02:46
  • I currently have some issue with update for ILB, will probably spawn a separate question for that... – smaikap Mar 24 '21 at 02:47