Kube ingress with hostname (how to know IP to forward domain name?)

3/10/2019

I see guides like this where setting up an Nginx Ingress (with ssl) requires you enter the host, i.e. echo1.example.com. I don't understand how you would be able to use the host specified if you didn't have the IP address (in your DNS, how would you know where to piont echo.example.com?).

When I set up an ingress like this, echo.example.com would show up as the ingress ADDRESS, so I don't know the IP. If I don't specify it, the ADDRESS is just empty. With this, how am I suppose to know what IP I'm suppose to point my domain name?

I'm running on GKE.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: echo-ingress
  annotations:  
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-staging
spec:
  tls:
  - hosts:
    - echo1.example.com
    - echo2.example.com
    secretName: letsencrypt-staging
  rules:
  - host: echo1.example.com
    http:
      paths:
      - backend:
          serviceName: echo1
          servicePort: 80
  - host: echo2.example.com
    http:
      paths:
      - backend:
          serviceName: echo2
          servicePort: 80
-- Display name
google-kubernetes-engine
hostname
ip-address
kubernetes
nginx-ingress

2 Answers

3/29/2019

The IPs of your Kubernetes nodes should be considered ephemeral. Do not point hostnames at them for purposes of hosting websites and services.

  1. Reserve an external static IP address
  2. Create a load balancer on ports 80 and 443. Use HTTPS if you want the load balancer to handle TLS. Use TCP if you want nginx to handle TLS
  3. Configure Target Pools on the load balancer to point to your K8s node pools on the correct nginx ingress port
  4. Point all hostnames served by the cluster at the external static IP address
-- ryanhos
Source: StackOverflow

3/10/2019

You can not specify the IP Adress that's going to be assigned by GKE. The IP is assigned automatically from google's IP Block.

You have to create the Ingress Resource, wait till the IP is assigned and then add the IP to your DNS.

If you want to automatically create a proper DNS entry which is pointing to your Ingress IP you should have look into: https://github.com/kubernetes-incubator/external-dns

-- stvnwrgs
Source: StackOverflow