kubernetesopenfaas

Kubernetes port forwarding between host machine and nodes? #LoadBalancer


I had 1 mission this weekend, get OpenFaas Cloud working on my home server. Disclaimer, I know very little about Kubernetes.

I have been following the OpenFaas Cloud guide here. The slack group has been very helpful but I still stuck: https://github.com/openfaas-incubator/ofc-bootstrap

So I have a kubernetes cluster on a host machine(Ubuntu 16.04). Its IP is 192.168.0.98.

I would like to map port 80 on my host(192.168.0.98) so that it sends the traffic to the LoadBalancer(10.104.107.60)

kubernetes                                   ClusterIP      10.96.0.1       <none>        443/TCP                      6h30m

nginxingress-nginx-ingress-controller        LoadBalancer   10.104.107.60   <pending>     80:31166/TCP,443:30837/TCP   4h42m

nginxingress-nginx-ingress-default-backend   ClusterIP      10.97.123.87    <none>        80/TCP                       4h42m

The LoadBalancer is running nginx-ingress, when I asked about the port forwarding on the OpenFaas group they mentioned:

Nginx -> router -> auth -> gateway -> function

On the cloud a load balancer gets an IP and you set the DNS then accessing the load balancer corresponds to nginx You are on premise so you need to edit your nginx config so that it binds to port 80/443 or use HAProxy on the host to forward to the nginx you have running on the node inside the cluster.

This went a little beyond my skillset :(


Solution

  • You can quite easily change the LoadBalancer service type to NodePort one, by upgrading nginx-ingress-controller`s corresponding helm chart:

    helm upgrade nginxingress stable/nginx-ingress --set \
    controller.service.type=NodePort --recreate-pods
    

    You should be able now to hit the openfaas gateway via http://localhost_ip:node_port/