What value should I use for host in a kubernetes ingress manifest?

6/19/2020

I have this yaml for an Ingress:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: app
  namespace: ingress-controller
... omitted for brevity ...
spec:
  rules:
    - host: ifs-alpha-kube-001.example.com
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-nodeport
              servicePort: 80
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-nodeport
              servicePort: 443
status:
  loadBalancer:
    ingress:
      - {}

In the above I set ...

    - host: ifs-alpha-kube-001.example.com

That host just happens to be one of my nodes. I have three nodes. I am pretty certain that this incorrect. The ingress works but if I shutdown ifs-alpha-kube-001 the ingress stops working. What should I set host if I want a high availability cluster?

Thanks

-- Red Cricket
kubernetes
kubernetes-ingress

1 Answer

6/20/2020

What should I set host if I want a high availability cluster?

The idea behind the Ingress resource is using the brower's host: HTTP header (which is sent for every request HTTP/1.1 and newer) for virtual hosting, so you can create one load balancer, but point all of your DNS records at the one host -- versus having to create a new load balancer for every Service in your cluster

Thus, the host: header would be whatever DNS name you wished for the outside world to be able to reach your Service as; for example, if you have a website and a reporting web-app in your cluster, one host: might be www.example.com and the other host: might be reports.example.com but both would be CNAME records for my-k8s-lb.example.com

-- mdaniel
Source: StackOverflow