Can i use a GCP HTTPS Load Balancer to route between a bucket backend and a Kubernetes service?

9/25/2019

i wanted to understand what are my load balancing options in a scenario where i want to use a single HTTPS Load Balancer on GCP to serve some static content from a bucket and dynamic content using a combination of react front end and express backend on Kubernetes.

Additional info:

  • i have a domain name registered outside of Google Domains
  • I want to serve all content over https
  • I'm not starting with anything big. Just getting started with a more or less hobby type project which will attract very little traffic in the near future.
  • I dont mind serving my react front end, express backend from app engine if that helps simplify this somehow. however, in such a case, i would like to understand if i still want something on kubernetes, will i be able to communicate between app engine and kubernetes without hassles using internal IPs. And how would i load balance that traffic!!

Any kind of network blueprint in the public domain that will guide me will be helpful.

I did quite a bit of reading on NodePort/LoadBalancer/Ingress which has left me confused. from what i understand, LoadBalancer does not work with HTTP(S) traffic, operates more at TCP L4 Level, so probably not suitable for my use case.

Ingress provisions a dedicated Load Balancer of its own on which i cannot put my own routes to a backend bucket etc, which means i may need a minimum of two load balancers? and two IPs?

NodePort exposes a port on all nodes, which means i need to handle load balancing myself even if my HTTPS Load balancer routing can somehow help.

Any guidance/pointers will be much appreciated!

EDIT: Found some information on Network Endpoint Groups (NEG) while researching. Looking promising. will investigate. Any thoughts about taking this route? https://cloud.google.com/kubernetes-engine/docs/how-to/standalone-neg

EDIT: Was able to get this working using a combination of NEGs and Nginx reverse proxies.

-- Denounce'IN
google-cloud-platform
kubernetes
load-balancing

1 Answer

9/27/2019

In order to resolve your concerns please start with:

  1. Choosing the right loadbalncer:

    • Network load balancer (Layer 4 load balancing or proxy for applications that rely on TCP/SSL protocol) the load is forwarding into your systems based on incoming IP protocol data, such as address, port, and protocol type.

      The network load balancer is a pass-through load balancer, so your backends receive the original client request. The network load balancer doesn't do any Transport Layer Security (TLS) offloading or proxying. Traffic is directly routed to your VMs. Network loadbalancers terminatese TLS on backends that are located in regions appropriate to your needs

    • HTTP(s) loadbalancer is a proxy-based, regional Layer 7 load balancer that enables you to run and scale your services behind a private load balancing IP address that is accessible only in the load balancer's region in your VPC network.

      HTTPS and SSL Proxy load balancers terminate TLS in locations that are distributed globally. An HTTP(S) load balancer acts as a proxy between your clients and your application. If you want to accept HTTPS requests from your clients You have the option to use Google-managed SSL certificates (Beta) or to use certificates that you manage yourself.

      Technical Details When you create an Ingress object, the GKE Ingress controller configures a GCP HTTP(S) load balancer according to the rules in the Ingress manifest and the associated Service manifests. The client sends a request to the HTTP(S) load balancer. The load balancer is an actual proxy; it chooses a node and forwards the request to that node's NodeIP:NodePort combination. The node uses its iptables NAT table to choose a Pod. kube-proxy manages the iptables rules on the node. Routes traffic is going to a healthy Pod for the Service specified in your rules.

  2. Per buckets documentation:

    An HTTP(S) load balancer can direct traffic from specified URLs to either a backend bucket or a backend service. Bucket should be public while using Loadbalncer- Creating buckets bucket

  3. During LoaBalancer set-up you can choose backend service and backend bucket. You can find more information in the docs.

Please take a look also for this two tutorials here and here how to build application using cloud storage.

Hope this help.

Additional resources: Loadbalancers, Controllers

-- Hanx
Source: StackOverflow