Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 294
Alexander Kleinhans Avatar asked Mar 10 '19 12:03

Alexander Kleinhans


People also ask

How do I map a static IP to a domain?

This tutorial demonstrates the following steps: Reserve a static external IP address for your application. Configure either Service or Ingress resources to use the static IP. Update DNS records of your domain name to point to your application.

Which ingress is used to route traffic from single IP to multiple services?

When you use an ingress controller and ingress rules, a single IP address can be used to route traffic to multiple services in a Kubernetes cluster. This article shows you how to deploy the NGINX ingress controller in an Azure Kubernetes Service (AKS) cluster.

What is ingress in Kubernetes?

1. Overview on Kubernetes Ingress Kubernetes offers an ingress resource and controller that is designed to expose Kubernetes services to the outside world. It can do the following: Ingresses do not work like other Services in Kubernetes. Just creating the Ingress itself will do nothing. You need two additional components:

How do I register a domain name in Kubernetes?

You can register a domain name through Google Domains or another domain registrar of your choice if you do not have one. Note: This tutorial uses the built-in GKE Ingress Controller and does not apply to the NGINX Ingress Controller. This tutorial demonstrates the following steps: Visit the Kubernetes Engine page in the Google Cloud Console.

How do I port forward from localhost to kubectl?

Specify Local IP Address for Port Forwarding. Listen on port 8080 on the localhost using the defined IP, forward to port 5762 in the pod: kubectl port-forward --address localhost,10.153.40.102 pod/mongo-db-r3pl1ka3 8080:5762.

Do I need to reserve a global IP address for ingress?

If you choose to expose your application using an Ingress , which creates an HTTP (S) Load Balancer, you must reserve a global static IP address . Regional IP addresses do not work with Ingress.


2 Answers

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
like image 152
ryanhos Avatar answered Oct 11 '22 09:10

ryanhos


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

like image 29
stvnwrgs Avatar answered Oct 11 '22 09:10

stvnwrgs