<p>I would like to deploy an ngingx-ingress controller on my self-hosted Kubernetes (microk8s) that is configurable to listen on one or more interfaces (external IPs).</p>
<p>Not even sure if that is easily possible and I should just switch to an external solution, such as HAProxy or an nginx.</p>
<p>Required behavior:</p>
<pre><code>192.168.0.1-H&quot;domain.com&quot;:443/frontend -&gt; 192.168.0.1 (eth0) -&gt; ingress -&gt; service-frontend
192.168.0.1-H&quot;domain.com&quot;:443/backend -&gt; 192.168.0.1 (eth0) -&gt; ingress -&gt; service-backend
88.88.88.88-H&quot;domain.com&quot;:443/frontend -&gt; 88.88.88.88 (eth1) -&gt; ? -&gt; [403 or timeout]
88.88.88.88-H&quot;domain.com&quot;:443/backend -&gt; 88.88.88.88 (eth1) -&gt; ? -&gt; [403 or timeout]
</code></pre>
<p>And then later the eth1 interface should be able to be switched on, so that requests on that interface behave the same as on eth0.</p>
<p>I would like to be able to deploy multiple instances of services for load-balancing. I would like to keep the configuration in my namespace (if possible) so I can always delete and apply everything at once.</p>
<p>I'm using this guide as a reference: <a href="https://kubernetes.github.io/ingress-nginx/deploy/baremetal/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/deploy/baremetal/</a></p>
<p>I was able to get something working with minikube, but obviously could not expose any external IPs and performance was quite bad. For that, I just configured a &quot;kind: Ingress&quot; and that was it.</p>
<p>So far, the ingress controller that's default on microk8s seems to listen on all interfaces and I can only configure it in its own namespace. Defining my own ingress seems to not have any effect.</p>

<blockquote>
<p>I would like to deploy an ngingx-ingress controller on my self-hosted
Kubernetes (microk8s) that is configurable to listen on one or more
interfaces (external IPs).</p>
</blockquote>
<p>For above scenario, you have to deploy the multiple ingress controller of Nginx ingress and keep the different <strong>class name</strong> in it.</p>
<p>Official document : <a href="https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/</a></p>
<p>So in this scenario, you have to create the Kubernetes service with <strong>Loadbalancer</strong> IP and each will point to the respective deployment and class will be used in the ingress object.</p>
<p>If you looking forward to use the multiple domains with a single ingress controller you can easily do it by mentioning the host into ingress.</p>
<p>Example for two domain :</p>
<ol>
<li>bar.foo.dev</li>
<li>foo.bar.dev</li>
</ol>
<p>YAML example</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: frontdoor-bar
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
spec:
  tls:
    - hosts:
        - bar.foo.dev
      secretName: tls-secret-bar
  rules:
    - host: bar.foo.dev
      http:
        paths:
          - backend:
              serviceName: barfoo
              servicePort: 80
            path: /(.*)
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: frontdoor-foo
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
    - hosts:
        - foo.bar.dev
      secretName: tls-secret-foo
  rules:
    - host: foo.bar.dev
      http:
        paths:
          - backend:
              serviceName: foobar
              servicePort: 9000
            path: /(.*)
</code></pre>
