<p>In kubernetes, if I have a ingress resource below, how does it know what type of Ingress Controller or which Ingress Controller (if I have multiple) to use?</p>
<blockquote>
<p>apiVersion: extensions/v1beta1 kind: Ingress metadata: name:
test-ingress spec:  rules:</p>
<ul>
<li>http:
paths:
<ul>
<li>path: /testpath
backend:
serviceName: test
servicePort: 80 &quot;</li>
</ul>
</li>
</ul>
</blockquote>

ilovesun
<p>They are tied by <a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/#using-multiple-ingress-controllers" rel="nofollow noreferrer">ingress class</a> concept.<br />
Each ingress controller is defined by some IngressClass.</p>
<p>In a nutshell <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#ingressclassspec-v1-networking-k8s-io" rel="nofollow noreferrer">IngressClass</a> is a simple wrapper object, which contains:</p>
<ul>
<li>mandatory <code>controller</code> field which is a pointer to actual ingress controller binary,</li>
<li>optional <code>parameters</code> field for additional configuration.</li>
</ul>
<p>Typically you would use predefined IngressClasses shipped with standard controllers, but nothing prevents you to <a href="https://stackoverflow.com/questions/64781320/ingress-controller-name-for-the-ingress-class">define</a> your own (though it's rarely needed in practice).</p>
<p>Each ingress rule may be marked with corresponding <code>ingress.class</code> annotation.<br />
E. g. <code>kubernetes.io/ingress.class: nginx</code></p>
<p>Also you may set a <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#default-ingress-class" rel="nofollow noreferrer">default ingress class</a> in you cluster.<br />
In this case ingress rules without class annotations will assume this default class.</p>
