Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose kubernetes nginx-ingress service on public node IP at port 80 / 443?

I installed ingress-nginx in a cluster. I tried exposing the service with the kind: nodePort option, but this only allows for a port range between 30000-32767 (AFAIK)... I need to expose the service at port 80 for http and 443 for tls, so that I can link A Records for the domains directly to the service. Does anyone know how this can be done?

I tried with type: LoadBalancer before, which worked fine, but this creates a new external Load Balancer at my cloud provider for each cluster. In my current situation I want to spawn multiple mini clusters. It would be too expensive to create a new (digitalocean) Load Balalancer for each of those, so I decided to run each cluster with it's own internal ingress-controller and expose that directly on 80/443.

like image 791
Rotareti Avatar asked Apr 02 '18 04:04

Rotareti


People also ask

How do I assign a static IP to ingress controller?

To acquire a static IP for the ingress-nginx-controller, simply put it behind a Service of Type=LoadBalancer . Then, update the ingress controller so it adopts the static IP of the Service by passing the --publish-service flag (the example yaml used in the next step already has it set to "ingress-nginx-lb").

How do I access NGINX in Kubernetes?

With this service-type, Kubernetes will assign this service on ports on the 30000+ range. Run the get svc command to see a summary of the service and the ports exposed. Now you can verify that the Nginx page is reachable on all nodes using the curl command. As you can see, the “WELCOME TO NGINX!” page can be reached.


2 Answers

if you are on bare metal so change your ingress-controller service type to NodePort and add a reverse proxy to flow traffic to your ingress-controller service with selected NodePort.

As @Pramod V answerd if you use externalIP in ingress-controller service so you loose real remote address in your EndPoints.

A more complete answer could be found Here

like image 20
Mozafar Gholami Avatar answered Sep 22 '22 19:09

Mozafar Gholami


If you want on IP for 80 port from a service you could use the externalIP field in service config yaml. You could find how to write the yaml here Kubernetes External IP

But if your usecase is really like getting the ingress controller up and running it does not need the service to be exposed externally.

like image 64
Pramod V Avatar answered Sep 24 '22 19:09

Pramod V