<p>I am trying to automate the hosts in Ingress Controller and I'm facing the problem of generating many hosts into one file. What I mean is, I have this ingress.yaml:</p>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-host
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/default-backend: a
spec:
  rules:
  - host: a.example.com
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: a
            port:
              number: 80
  - host: b.example.com
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: b
            port:
              number: 80
  ...
  - host: x.example.com
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: x
            port:
              number: 80
...

</code></pre>
<p>in this example I have multiple instances: <code>a</code>, <code>b</code>, all the way to <code>x</code> and I anticipate a lot more. Right now I am programmatically regenerating the whole ingress.yaml to add/remove certain hosts. This is prone to errors and hard to maintain, as I must constantly be aware about <code>ingress.yaml</code> to be broken for one reason or another.</p>
<p>What would really help me is to put every <code>host</code> into a separate file and (maybe) just tell <code>ingress.yaml</code> to scan the whole directory where those files are to be stored. This way, I can just add/remove a single file and reload Ingress</p>
<p>Is there an option for that? I found somewhere that <code>IngressSpec</code> could be somehow defined, but I do not see any usefull link with a valid example. Maybe someone found a solution to that already and can point me to the right direction?</p>

Kevin Kopf
<p>As @jordanm suggested in the comment, I went with multiple Ingress objects on one <code>IngressController</code>, being sure I get rid of <code>nginx.ingress.kubernetes.io/default-backend</code> annotation:</p>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-x-host
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: x.example.com
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: x
            port:
              number: 80
</code></pre>
<p>I generate a unique file for each of hosts, replacing <code>x</code> with my unique name.</p>
<p>I also have to make sure that <code>metadata.name</code> is unique. If <code>metadata.name</code> is the same for every object, then it just gets replaced as I <code>apply</code> the new configuration. This works perfectly.</p>
