Warm tip: This article is reproduced from serverfault.com, please click

GKE Ingress for HTTPS and LoadBalancer for TCP on same backend?

发布于 2020-12-02 15:22:27

The usecase is this: I have a RabbitMQ cluster with STOMP over websocket. The websocket uses SSL (wss:x.x.x.x). I have an Ingress set up to handle the certificates. It forwards the traffic to internal port 15674. The RabbitMQ also needs to accept TCP on port 5672.

The Ingress load balancer does not do TCP, it is L7. The Service LoadBalancer does not do HTTPS, it is L4.

Is it possible to set up an Ingress and a Service LoadBalancer that points at the same back end but different ports? Is there another way to do this?

Questioner
Heinrich Venter
Viewed
11
Frank 2020-12-03 02:08:52

GKE Ingress is only for HTTP / HTTPS / "HTTP/2" (TLS) traffic, you can create a GKE TCP LB that points to the same backend you have on a different port.

Something like this:

apiVersion: "v1"
kind: "Service"
metadata:
  name: "l4-loadbalancer"
  namespace: "default"
  labels:
    app: "nginx"
spec:
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  selector:
    app: "nginx"
  type: "LoadBalancer"
  loadBalancerIP: ""

You can also handle all of this by only using a GKE tcp load balancer, but the downside would be that you would need to handle your SSL certs on your backend directly, if you want GCP to handle this, then the 2 load balancer approach would be better.