HTTPS Load Balancer to expose a Workload on Google Kubernetes

12/10/2018

I created a custom HTTPS LoadBalancer (details) and I need my Kubernetes Workload to be exposed with this LoadBalancer. For now, if I send a request to this endpoint I get the error 502.

When I choose the Expose option in the Workload Console page, there are only TCP and UDP service types available, and a TCP LoadBalancer is created automatically.

How do I expose a Kubernetes Workload with an existing LoadBalancer? Or maybe I don't even need to do it, and requests don't work because my instances are "unhealthy"? (healthcheck)

-- Yolo Tolo
google-cloud-platform
google-kubernetes-engine
https
kubernetes
load-balancing

1 Answer

12/10/2018

You need to create a kubernetes ingress. First, you need to expose the deployment from k8s, for a https choose 443 port and service type can be either: LoadBalance(external ip) or ClusterIp. (you can also test that by accesing the ip or by port forwarding).

Then you need to create the ingress.

Inside yaml file when choosing the backend, set the port and ServiceName that was configured when exposing the deployment. For example:

- path: /some-route backend: serviceName: your-service-name servicePort: 443

On gcp, when ingress is created, there will be a load balancer created for that. The backends and instance groups will be automatically build too. Then if you want to use the already created load balancer you just need to select the backend services from the lb that was created by ingress and add them there.

Also the load balancer will work only if the health checks pass. You need to use the route that will return a 200 HTTPS response for that.

-- Nicolae
Source: StackOverflow