Search code examples
kubernetesminikubeingress-controller

Reason for service need to be nodeport to be routed by ingress


As I am following the Kubernetes website regarding setting up ingress on minikube, it's all the more confusing... (https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/)

However, here I am summarizing what I have understood so far and question will follow after:

  1. When you just use Minikube provided ingress controller (command: Minikube addons enable ingress), it deploys ingress-nginx-controller as 'NodePort' type at namespace 'ingress-nginx' (huh..? Why such a specific namespace..? so the ingress controller can be at a different namespace than my services..? btw when I do 'kubectl apply -f my-services, they all deploy under namespace 'default')

  2. You still need the manifest or rule created (command example: kubectl apply -f ingress.yaml) and IT'S OK to have the ingress controller to have different namespace as long as in this ingress.yaml you specify namespace to be the namespace where your services are deployed.

  3. Once you deployed ingress-controller and created ingress object (or manifest) via yaml, then you can route external request to the routed services as long as these services are deployed as 'NodePort'... wait a sec... didn't I already deploy nginx-controller as 'NodePort' type... ?

Why does the website above guide me to create services as NodePort type.. ? Wouldn't the ingress object (or manifest) take care of having to have to expose these services as NodePort ?? The manifest (such as ingress.yaml) already has all those port and service routing definitions..?


Solution

  • As per the given kubernetes doc, when you try to deploy using the minikube, first it is deployed as a node port type with ingress-nginx namespace instead of the kube-system namespace due to ingress version updates.

    Why does the website above guide me to create services as NodePort type :

    The doc has taken service reference as NodePort type and hence it created a service as NodePort type. You can also use any other service type(like load balancer) as per your need.

    We need to expose the port number so that service can run on that particular port only. This will help in routing the request to the service.