<p>I don't see any link between the service and Ingress yaml files. How is it linked and how does it work? I looked at the nginx ingress controller but couldn't find any links to the ingress either.</p>
<p>How does the traffic flow? <code>LB -&gt; Ingress controller -&gt; Ingress -&gt; Backend service -&gt; pods</code>? And it seems only 80 and 443 are allowed by ingress. Does that mean any custom ports defined on <code>ingress-nginx service</code> is directly connected to the pod through like <code>LB -&gt; Backend service -&gt; Pod</code>?</p>
<p>Update: Figured out the traffic flow. Its as follows:
<code>LB -&gt; Ingress controller -&gt; Ingress -&gt; Backend service -&gt; pods</code></p>
<p>I have a <code>https virtual host with a custom port</code> and I guess I need to edit the <code>ingress-controller</code> yaml file to allow custom port and add the custom port to ingress and would it start routing?</p>
<p><code>Ingress.yml:</code></p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test
  namespace: test
  rules:
    - path: /
      backend:
        serviceName: httpd
        servicePort: 443
</code></pre>
<p><code>cloud-generic-service.yml:</code></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
data:
  1234: &quot;test-web-dev/httpd:1234&quot;
  1235: &quot;test-web-dev/tomcat7:1235&quot;
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      port: 443
      protocol: TCP
      targetPort: https
    - name: port-1234
      port: 1234
      protocol: TCP
      targetPort: 1234
    - name: port-1235
      port: 1235
      protocol: TCP
      targetPort: 1235
</code></pre>

user630702
<p>Explanation to this can be found <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#what-is-ingress" rel="nofollow noreferrer">in the documentation</a></p>
<blockquote>
<p>Ingress exposes HTTP and HTTPS routes from outside the cluster to
services within the cluster. Traffic routing is controlled by rules
defined on the Ingress resource.</p>
<p>An Ingress may be configured to give Services externally-reachable
URLs, load balance traffic, terminate SSL / TLS, and offer name-based
virtual hosting.</p>
</blockquote>
<p>So <code>Ingress</code> routes traffic from outside the cluster to service that you've specified in it, <code>httpd</code> in your example. You can specify how traffic should be used by <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/" rel="nofollow noreferrer">adding annotations</a> (example of annotation for nginx ingress).</p>
<blockquote>
<p>The Ingress controller is an application that runs in a cluster and
configures an HTTP load balancer according to Ingress resources. The
load balancer can be a software load balancer running in the cluster
or a hardware or cloud load balancer running externally. Different
load balancers require different Ingress controller implementations.</p>
</blockquote>
<blockquote>
<p>In the case of NGINX, the Ingress controller is deployed in a pod along with the &gt; load balancer.</p>
</blockquote>
<p><code>Ingress</code> resources requires <a href="https://kubernetes.github.io/ingress-nginx/how-it-works/#how-it-works" rel="nofollow noreferrer"><code>Ingress controller</code></a> to be present in the cluster. It is not deployed in to the cluster by default that's why it has has to be installed manually.</p>
