<p>I have two ingress controllers (for public/internal traffic), what I would like is for all endpoints to use the public ingress except for /metrics, which should be internal, all using the same host.</p>
<p>E.g.</p>
<pre><code>example.com/ -&gt; public ingress
example.com/metrics -&gt; internal ingress
</code></pre>
<p>This is what I have tried:</p>
<p>internal ingress</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-metrics-ingress
  annotations:
    kubernetes.io/ingress.class: ingress-internal
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /metrics
        backend:
          serviceName: example-servicename
          servicePort: 80
</code></pre>
<p>and public ingress</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path:
        backend:
          serviceName: example-servicename
          servicePort: 80
</code></pre>
<p>The internal ingress is currently being ignored when I visit example.com/metrics (it uses the public one instead).</p>
<p>If I change the internal ingress to use the same ingress controller as the public one and change the service port to 81 (as an example), this provides an error (which is expected), this shows that the two different ingresses are being used. However, as soon as I use two different ingress controllers, then the one ingress' rules are not being picked up.</p>
<p>How can I configure my ingresses to achieve my desired result?</p>

<p>When running multiple ingress-nginx controllers, it will only process an unset class annotation if one of the controllers uses the default  <code>--ingress-class</code>  value (see  <code>IsValid</code>  method in  <code>internal/ingress/annotations/class/main.go</code>), otherwise the class annotation become required.</p>
<p>If  <code>--ingress-class</code>  is set to the default value of  <code>nginx</code>, the controller will monitor Ingresses with no class annotation  <em>and</em>  Ingresses with annotation class set to  <code>nginx</code>. Use a non-default value for  <code>--ingress-class</code>, to ensure that the controller only satisfied the specific class of Ingresses.</p>
<p>In your case use the combination of the annotation <code>kubernetes.io/ingress.class: &quot;EXTERNAL|INTERNAL&quot;</code> and the flag <code>--ingress-class=EXTERNAL|INTERNAL</code> allows you to filter which Ingress rules should be picked by the nginx ingress controller.</p>
<p>Take a look: <a href="https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/" rel="nofollow noreferrer">multiple-ingress</a>, <a href="https://github.com/kubernetes/ingress-nginx/issues/1976" rel="nofollow noreferrer">ingress-nginx-traffic</a>.</p>
