<p>I am trying to create an ingress that routes to <strong>service1</strong> when <strong>service1.domain.com</strong> is entered &amp; <strong>service2</strong> when <strong>service2.domain.com</strong> is entered.
My ingress file looks like this below.
I am on Azure AKS and using Azure App gateway as my ingress controller. Below is how my ingress yaml looks like.</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app-ingress
  annotations: 
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - host: service1.domain.com
  - http:
      paths:
      - path: /
        backend:
          service:
            name: service1
            port:
              number: 80
        pathType: Prefix      
  - host: service2.domain.com
  - http:
      paths:
      - path: /
        backend:
          service:
            name: service2
            port:
              number: 80
        pathType: Prefix
</code></pre>
<p>However, both the domains are getting routed to service2. Can someone help what I am missing here.</p>

Shubzumt
<p>The spec look wrong. It should be:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app-ingress
  annotations: 
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - host: service1.domain.com
    http:
      paths:
      - path: /
        backend:
          service:
            name: service1
            port:
              number: 80
        pathType: Prefix      
  - host: service2.domain.com
    http:
      paths:
      - path: /
        backend:
          service:
            name: service2
            port:
              number: 80
        pathType: Prefix
</code></pre>
<p>There should be two items in your rules, one for each subdomain. <code>http</code> and <code>host</code> are two fields of the same item.</p>
