<p>all</p>

<ol>
<li><p>I knew well about k8s' nodePort and ClusterIP type in services.</p></li>
<li><p>But I am very confused about the Ingress way, because how will a request come into a pod in k8s by this Ingress way? </p></li>
</ol>

<p>Suppose K8s master IP is <strong>1.2.3.4</strong>, after Ingress setup, and can connect to backend service(e.g, <strong>myservice</strong>) with a port(e.g, <strong>9000</strong>)</p>

<p>Now, How can I visit this <strong>myservice:9000</strong> outside? i.e, through <strong>1.2.3.4</strong>? As there's no entry port on the <strong>1.2.3.4</strong> machine.</p>

<p>And many docs always said visit this via 'foo.com' configed in the ingress YAML file. But that is really funny, because <strong>xxx.com</strong> definitely needs DNS, it's not a magic to let you new-invent any <strong>xxx.com</strong> you like be a real website and can map your <strong>xxx.com</strong> to your machine!</p>

<p>The key part of the picture is the <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-controllers" rel="nofollow noreferrer">Ingress Controller</a>. It's an instance of a proxy (<a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-controllers" rel="nofollow noreferrer">could be nginx or haproxy or another ingress type</a>) and runs inside the cluster. It acts as an entrypoint and lets you add more sophisticated routing rules. It reads <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource" rel="nofollow noreferrer">Ingress Resources</a> that are deployed with apps and which define the <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules" rel="nofollow noreferrer">routing rules</a>. This allows each app to say what the Ingress Controller needs to do for routing to it.</p>

<p>Because the controller runs inside the cluster, it needs to be exposed to the outside world. You can do this by NodePort but if you're using a cloud provider then it's more common to use LoadBalancer. This gives you an external IP and port that reaches the Ingress controller and you can point DNS entries at that. If you do point DNS at it then you have the option to use routing rules base on DNS (such as using different subdomains for different apps).</p>

<p>The article <a href="https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0" rel="nofollow noreferrer">'Kubernetes NodePort vs LoadBalancer vs Ingress? When should I use what?'</a> has some good explanations and diagrams - here's the diagram for Ingress:</p>

<p><a href="https://i.stack.imgur.com/bfEDw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bfEDw.png" alt="enter image description here"></a></p>
