5

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

anish anil
  • 2,299
  • 7
  • 21
  • 41
  • 1
    Ingress should work just fine with `ClusterIP` type services, so it's probably something about your yaml files. – BogdanL Aug 13 '20 at 19:31
  • Please share your YAML. Also, can you tell us more about your cluster? Kubernetes version, where is it running (aws? gke? bare-metal ? ...) – SYN Aug 15 '20 at 23:54

1 Answers1

4

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.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Could be beneficiary to add that some `Ingress` controllers like `nginx-ingress` can work with either `clusterIP` or `nodePort` type of services. – Dawid Kruk Aug 14 '20 at 12:35