How to access kubernetes application through ingress only

4/11/2021

I have a kubernetes objects as below:

  1. a deployment
  2. a service to use with that deployment in step 1
  3. an ingress with backend paths to the service in step 2

I am using Kubernetes Engine in GCP. Once I created an ingress object, it created a load balancer as usual.

So I have my dns, and I added a A record with a domain name test1.<my-domain>.co pointing to the IP of the LoadBalancer created from the ingress

But this is not working. It doesn't load the page.

Then I tried installing ningx ingress controller, and once that is being deployed, it created another load balancer in the gcp. So, I got the IP of that newly created load balancer and switched/changed replace the DNS record IP with newly created Load Balancer's IP. And voila, it started working. So does that mean, an ingress always need an ingress controller to work?

-- Jananath Banuka
google-kubernetes-engine
kubernetes
kubernetes-ingress
nginx-ingress

2 Answers

4/11/2021

Yes, in order for the Ingress resource to work, the cluster must have an ingress controller running. Only creating an Ingress resource has no effect.
An Ingress controller is responsible for fulfilling the Ingress, usually with a load balancer, which is what you see.

A request from the client lands up on the Ingress managed Load Balancer which is forwarded to the respective Ingress based on the host and path in the original request. Following the routing rules defined in the ingress, request is forwarded to the service from where it lands up on the backend pods.

Ingress resource creating its own Load Balancer seems to be a behaviour followed in GKE. From the GCP docs

When you specify kind:Ingress in the resource manifest, you instruct GKE to create an Ingress resource. By including annotations and supporting workloads and Services, you can create a custom Ingress controller. Otherwise, GKE makes appropriate Google Cloud API calls to create an external HTTP(S) load balancer.

You can read more about this here.

-- rock&#39;n rolla
Source: StackOverflow

4/11/2021

yes ingress controller is needed to serve user request comes outside the cluster. when user sends request on load balancer IP of ingress controller ingress controller reads route from ingress resource and forward user request accordingly. ingress resource is a part of service. means for every service you need to have ingress resource where as a ingress controller can serve multiple ingress resource.

There are mainly two ingress controller used. 1. nginx 2. contour. you can read about them in details.

-- Rakesh Singh Rana
Source: StackOverflow