title: AWS Ingress Controller seems to be ignoring host name rules
body: <p>I am trying to deploy a frontend application to Amazon EKS. The concept is that there will be two deployments as well as two services (<code>frontend-service</code> and <code>stg-frontend-service</code>), one for production and one for staging.</p>
  <p>On top of that, there will be an ingress ALB which will redirect traffic based on the hostname. i.e. if the hostname is <code>www.project.io</code>, traffic will be routed to <code>frontend-service</code> and if the hostname is <code>stg-project.io</code>, traffic will be routed to <code>stg-frontend-service</code>.</p>
  <p>Here are my deployment and ingress configs</p>
  <p><code>stg-frontend-deployment.yaml</code></p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: stg-frontend-deployment
    namespace: project
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: stg-frontend
    template:
      metadata:
        labels:
          app: stg-frontend
      spec:
        containers:
          - name: stg-frontend
            image: STAGING_IMAGE
            imagePullPolicy: Always
            ports:
              - name: web
                containerPort: 3000
        imagePullSecrets:
          - name: project-ecr
  
  ---
  
  apiVersion: v1
  kind: Service
  metadata:
    name: stg-frontend-service
    namespace: project
  spec:
    selector:
      app: stg-frontend
    ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
  </code></pre>
  <p><code>stg-prod-deployment.yaml</code></p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: frontend-deployment
    namespace: project
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: frontend
    template:
      metadata:
        labels:
          app: frontend
      spec:
        containers:
          - name: frontend
            image: PRODUCTION_IMAGE
            imagePullPolicy: Always
            ports:
              - name: web
                containerPort: 3000
        imagePullSecrets:
          - name: project-ecr
  
  ---
  
  apiVersion: v1
  kind: Service
  metadata:
    name: frontend-service
    namespace: project
  spec:
    selector:
      app: frontend
    ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
  </code></pre>
  <p><code>ingress.yaml</code></p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: project-ingress
    namespace: project
    annotations:
      kubernetes.io/ingress.class: alb
      alb.ingress.kubernetes.io/scheme: internet-facing
      alb.ingress.kubernetes.io/target-type: ip
  spec:
    rules:
    - host: www.project.io
    - http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: frontend-service
              port:
                number: 80
    - host: stg.project.io
    - http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: stg-frontend-service
              port:
                number: 80
  </code></pre>
  <p>Later, I have used Route 53 to route traffic from both domain to the ALB.</p>
  <pre><code>+----------------+------+---------+-----------------------------------------------------+
  |  Record Name   | Type | Routing |               Value/Route traffic to                |
  +----------------+------+---------+-----------------------------------------------------+
  | www.project.io | A    | Simple  | dualstack.k8s-********.us-west-1.elb.amazonaws.com. |
  | stg.project.io | A    | Simple  | dualstack.k8s-********.us-west-1.elb.amazonaws.com. |
  +----------------+------+---------+-----------------------------------------------------+
  </code></pre>
  <p>The problem is, ALB ingress is always routing traffic to the first spec rules. In the config above, the first rule is host <code>www.project.io</code> which refers to <code>frontend-service</code>. Whenever I am trying to access <code>www.project.io</code> or <code>stg.project.io</code>, it's showing me a response from <code>frontend-service</code>.</p>
  <p>Later, I have switched the rules and put staging rules first, and then it was showing staging service on both domains.</p>
  <p>I even created a dummy record like <code>junk.project.io</code> and pointed to the load balancer, it still worked and showed me the same response, even though <code>junk.project.io</code> is not included in my ingress config.</p>
  <p>It seems to me that Ingress Config is totally ignoring what the host name is and always returning response from the first rule.</p>