2

I'm creating a single node(name: node1) k8 cluster for demos. I have setup a nginx-ingress controller.

service/volted-marmot-nginx-ingress-controller        LoadBalancer   10.100.132.29   <pending>     80:30787/TCP,443:30043/TCP   3h48m

I can access it by node1_ip:30043 for e.g. How do I put a load balancer in front of it? What I want is to have loadbalancer_ip:443 point to node1_ip:30043. If that's the wrong way to think of it, please let me know. I can't do it anyway, as the target pool does not have any option to choose port(e.g. 30043) anyway.

If I set the loadbalancer port to 300043 then loadbalancer_ip:300043 works but I was hoping to hide that.

1 Answer 1

2

You can use the GCP HTTP(S) Load balancer. Since you are running a kubernetes cluster (Assuming you are using GKE), GKE uses Google compute VM instance groups which can be put behind a load balancer as target group.

You can follow the below steps to setup a load balancer and put your kubernetes node behind a load balancer.

  1. Login to GCP console and go to NETWORKING > Network Services > Load balancing
  2. Click on Create Load Balancer at the top of the page.
  3. Click on Start Configuration for HTTP(s) Load balancing
  4. Select From Internet to my VMs if you want to access it from public internet and click continue
  5. Give a Name to your load balancer
  6. Click on Backend Configuration and Select Backend services (from drop down) > Create a backend service
  7. Give a name to backend service and select the other parameters appropriately. Select Instance groups in Backend type.
  8. In the New backend section, select the kubernetes instance group name from the drop down. After selecting the proper instance group, you can enter the ports which will accept the requests. You can modify other things if required. At the end, click Create.
  9. Next you can setup Host and Path rules if you need any.
  10. Next, you have to configure Frontend configuration which will be your frontend to accept the requests on the port and send it to the backend target group which we configured in the step 8.
  11. Once all the configurations are done, click on Create to create your load balancer.

If everything was setup correctly, you should be able to access the contents from the load balancer endpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.