Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expose multiple backends with multiple IPs with Kubernetes Ingress resources

Tags:

I exposed a service with a static IP and an Ingress through an nginx controller as one of the examples of the kubernetes/ingress repository. I have a second LoadBalancer service, that is not managed by any Ingress resource that is no longer properly exposed after the adding the new resources for the first service (I do not understand why this is the case).

I tried to add a second Ingress and LoadBalancer service to assign the second static IP, but I cant get it to work.

How would I go about exposing the second service, preferably with an Ingress? Do I need to add a second Ingress resource or do I have to reconfigure the one I already have?

like image 451
Jan P Avatar asked Mar 09 '17 12:03

Jan P


People also ask

Can I have multiple ingress resources?

Combining multiple Ingress resources into a single Google Cloud load balancer is not supported.

Can Kubernetes have multiple ingress controllers?

You may deploy any number of ingress controllers using ingress class within a cluster. Note the .metadata.name of your ingress class resource.

Which ingress is used to route traffic from single IP to multiple services?

Kubernetes ingress resources are used to configure the ingress rules and routes for individual Kubernetes services. When you use an ingress controller and ingress rules, a single IP address can be used to route traffic to multiple services in a Kubernetes cluster.

What is the difference between ingress controller and ingress resource?

Ingress controllers only cover L7 traffic, while ingresses route HTTP and HTTPS traffic. It is not possible to route TCP and UDP traffic using an Ingress, even if the ingress controller supports L4 traffic.


1 Answers

Using a Service with type: LoadBalancer and using an Ingress are usually mutually exclusive ways to expose your application.

When you create a Service with type: LoadBalancer, Kubernetes creates a LoadBalancer in your cloud account that has an IP, opens the ports on that LoadBalancer that match your Service, and then directs all traffic to that IP to the 1 Service. So if you have 2 Service objects, each with 'type: LoadBalancer' for 2 different Deployments, then you have 2 IPs as well (one for each Service).

The Ingress model is based on directing traffic through a single Ingress Controller which is running something like nginx. As the Ingress resources are added, the Ingress Controller reconfigures nginx to include the new Ingress details. In this case, there will be a Service for the Ingress Controller (e.g. nginx) that is type: LoadBalancer, but all of the services that the Ingress resources point to should be type: ClusterIP. Traffic for all the Ingress objects will flow through the same public IP of the LoadBalancer for the Ingress Controller Service to the Ingress Controller (e.g. nginx) Pods. The configuration details from the Ingress object (e.g. virtual host or port or route) will then determine which Service will get the traffic.

like image 170
coreypobrien Avatar answered Sep 24 '22 10:09

coreypobrien