Search code examples
google-kubernetes-enginegoogle-cloud-networkinggoogle-cloud-load-balancer

Is it possible to provision a Google Cloud Internal TCP/UDP Load Balancer through GKE ingress?


I am using google GKE. I need an internal tcp pass-through load balancer to expose my service. The backend service can terminate TLS traffic. I could provision a tcp load balancer manually. But, I would like to manage loadbalancer through ingress. The google cloud documentation only talks about creating HTTP(S) L7 load balancer through Ingress.

Is it possible to provision a Google Cloud Internal TCP/UDP Loadbalancer through GKE ingress ?


Solution

  • If you just want to do internal TCP load balancing, then you don't need an Ingress resource; you can just expose your deployment via a Service of type LoadBalancer.

    apiVersion: v1
    kind: Service
    metadata:
      name: ilb-service
      annotations:
        networking.gke.io/load-balancer-type: "Internal"
      labels:
        app: myapp
    spec:
      type: LoadBalancer
      selector:
        app: myapp
      ports:
      - port: 80
        targetPort: 8080
        protocol: TCP
    

    The above will create an GCP Internal Load Balancer and balance incoming traffic on port 80 to your app running on port 8080.

    Note: The networking.gke.io/load-balancer-type: "Internal" is what creates an ILB versus a GLB in GCP.