snippetkubernetesMinor
How to connect GCP Load balancer to Kubernetes cluster(single node cluster)
Viewed 0 times
connecthowkubernetesnodesingleloadbalancergcpcluster
Problem
I'm creating a single node(name: node1) k8 cluster for demos. I have setup a nginx-ingress controller.
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.
service/volted-marmot-nginx-ingress-controller LoadBalancer 10.100.132.29 80:30787/TCP,443:30043/TCP 3h48mI 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.
Solution
You can use the GCP
You can follow the below steps to setup a load balancer and put your kubernetes node behind a load balancer.
If everything was setup correctly, you should be able to access the contents from the load balancer endpoint.
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.
- Login to GCP console and go to
NETWORKING>Network Services>Load balancing
- Click on
Create Load Balancerat the top of the page.
- Click on
Start ConfigurationforHTTP(s) Load balancing
- Select
From Internet to my VMsif you want to access it from public internet and clickcontinue
- Give a
Nameto your load balancer
- Click on
Backend Configurationand SelectBackend services(from drop down) >Create a backend service
- Give a name to backend service and select the other parameters appropriately. Select
Instance groupsinBackend type.
- In the
New backendsection, 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, clickCreate.
- Next you can setup
Host and Path rulesif you need any.
- Next, you have to configure
Frontend configurationwhich 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.
- Once all the configurations are done, click on
Createto create your load balancer.
If everything was setup correctly, you should be able to access the contents from the load balancer endpoint.
Context
StackExchange DevOps Q#10089, answer score: 2
Revisions (0)
No revisions yet.