anish anil
anish anil

Reputation: 2631

Do we need to keep the services as nodePort even if Ingress is being used?

Hello Kubernetes Experts,

Trying to get a better understanding here.

I have created a deployment with a regular deployment yaml and service yaml The service is node port, I then created a ingress and pointed the service

Tried to access the service and it works as expected on the default port of 80 on nginx ingress.

Next created the same deployment and service file. The only exception here was insted of node port is chose ClusterIP. Created a Ingress and pointed the service.

Tried to access the service and it simply fails with the nginx home page and does not do any routing to my application.

I understand that nodeport is what exposes the application to the external world. But then I'm using Ingress to attain the same functionality.

Do we really need to set the service as node port even if we use Ingress???

Or is something terribly wrong with my yaml files. I tried reading about it and could not get any relevant explanation.

Thank you, Anish

Upvotes: 5

Views: 838

Answers (1)

Jonas
Jonas

Reputation: 128787

First, the Service and Ingress resources works a bit different across cloud providers. E.g. on Google Cloud Platform and AWS, you need to use a NodePort service when using Ingress but on e.g. OpenShift ClusterIP is working.

Mostly, the reason is that the Load Balancer is located outside of your cluster (this is not the case on the OpenShift environment where I work).

From Google Cloud documentation, use NodePort for load balancing but ClusterIP if your load balancer is "container native".

In the Service manifest, you must use type: NodePort unless you're using container native load balancing. If using container native load balancing, use the type: ClusterIP.

Upvotes: 4

Related Questions