rj99999
rj99999

Reputation: 109

Kubernetes Ingress describe is not showing hostname

I have configured 2 nodes Kubernetes cluster in AWS using EC2 (Not using EKS). I have configured an Ingress controller using Traefik version 1.7. I have tried setting up rules in the ingress controller using the host. But when I do describe on the Ingress, my host is set to wildcard always.

Below is the Ingress YAML

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-test
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: www.random.com
  - http:
      paths:
      - backend:
          serviceName: secondapp
          servicePort: 80
        path: /

Here www.random.com is a junk hostname.

Below is the describe command out

Name:             ingress-test
Namespace:        default
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *
        /   secondapp:80 (192.168.1.132:80)
Annotations:
  kubernetes.io/ingress.class:  traefik

I am able to hit the webpage for this app from the EC2's external IP, but the Ingress controller is not doing any filtering based on the host. So hitting this page using curl by specifying the host in the header has no effect, ie: curl -H "Host: www.random.com" http://<external_ip>. Also, I am not able to access the Traefik GUI from the external IP. I am guessing this is because of the wildcarded host, as Ingress controller routes request bases on the hostnames. I searched through the network but could find anything around this. Would appreciate any help.

Upvotes: 0

Views: 1663

Answers (1)

Spazzy757
Spazzy757

Reputation: 929

Your ingress seems to be formatted incorrectly: you have an array under rules; however, your host needs to be part of the same object as your http:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-test
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: www.random.com
    # Note I removed the dash before http
    http:
      paths:
      - backend:
          serviceName: secondapp
          servicePort: 80
        path: /

This is untested but should resolve the problem

Upvotes: 4

Related Questions