<p>I have two separate IngressControllers, one internal and one external. I would like to define which controller to use for each Ingress.</p>
<p>I have defined <code>--ingress.class=hapxroxy-ext</code> arg for the external controller and <code>--empty-ingress-class</code> for the internal.</p>
<p>Ingress Services</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  annotations:
  labels:
    run: ext-haproxy-ingress
  name: ext-haproxy-ingress
  namespace: ext-haproxy-controller
spec:
  selector:
    run: ext-haproxy-ingress
  type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    &quot;service.beta.kubernetes.io/azure-load-balancer-internal&quot;: &quot;true&quot;
  labels:
    run: haproxy-ingress
  name: haproxy-ingress
  namespace: haproxy-controller
spec:
  selector:
    run: haproxy-ingress
  type: LoadBalancer
</code></pre>
<p>I have IngressClasses.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: external-lb
spec:
  controller: haproxy.org/ingress-controller/hapxroxy-ext
---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: internal-lb
  annotations:
    &quot;ingressclass.kubernetes.io/is-default-class&quot;: &quot;true&quot;
spec:
  controller: haproxy.org/ingress-controller
</code></pre>
<p>I have one Ingress</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
    &quot;kubernetes.io/ingress.class&quot;: internal-lb
spec:
  ingressClassName: internal-lb
...
</code></pre>
<p>Despite mapping the Ingress to just <code>internal-lb</code>, both <code>internal-lb</code> and <code>external-lb</code> handle requests.</p>
<p>It seems pretty straightforward in the <a href="https://www.haproxy.com/documentation/kubernetes/latest/configuration/controller/#--ingressclass" rel="nofollow noreferrer">docs</a>, but I'm missing something.</p>

logicaldiagram
<p>This issue is due to a bug in <a href="https://github.com/haproxytech/kubernetes-ingress" rel="nofollow noreferrer">https://github.com/haproxytech/kubernetes-ingress</a> when using IngressClassName in ingress.yaml. If you remove IngressClassName from your ingress.yaml and just use   &quot;kubernetes.io/ingress.class&quot;: annotation the issue goes away, it more of a workaround than a fix.</p>
<p>This issue has been raised and still open see link below for updates.</p>
<p><a href="https://github.com/haproxytech/kubernetes-ingress/issues/354#issuecomment-904551220" rel="nofollow noreferrer">https://github.com/haproxytech/kubernetes-ingress/issues/354#issuecomment-904551220</a></p>
