Kubernetes - Is it possible to set one public FQDN for many nodes?

Viewed 188

Let's say I have a Kubernetes cluster with 1 master node Master and 2 worker nodes Worker 1 and Worker 2. All have publicly reachable IP addresses.

  • Master has the IP 1.1.1.1
  • Worker 1 has the IP 2.2.2.2
  • Worker 2 has the IP 3.3.3.3

Additionally, let's assume my cluster exposes an nginx-webserver with a website on port 80 and I can reach it via any of the 3 nodes (e.g. 1.1.1.1:80 or 2.2.2.2:80 or 3.3.3.3:80 opens the same website). However, remembering the IP addresses is "difficult" and I would much rather like to remember a domain name. So I choose "www.flying-circus.uk" as my domain. But there is a problem: A public domain name is only assigned to one IP address, multiple IPs cannot have the same FQDN.

How can I configure my cluster so that the website is reachable from any node via the FQDN?

1 Answers

But there is a problem: A public domain name is only assigned to one IP address, multiple IPs cannot have the same FQDN

First, this statement is not absolutely true. An FQDN can point to multiple IP addresses. Something preventing you from doing that could be that your domain provider doesn't allow you to have the same FQDN with multiple DNS A pointers.

For example, yahoo.com, google.com point to different IPs:

$ dig yahoo.com

; <<>> DiG 9.10.6 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27299
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yahoo.com.         IN  A

;; ANSWER SECTION:
yahoo.com.      323 IN  A   98.138.219.231
yahoo.com.      323 IN  A   98.137.246.7
yahoo.com.      323 IN  A   98.138.219.232
yahoo.com.      323 IN  A   98.137.246.8
yahoo.com.      323 IN  A   72.30.35.10
yahoo.com.      323 IN  A   72.30.35.9

;; Query time: 51 msec
;; SERVER: 10.240.246.53#53(10.240.246.53)
;; WHEN: Tue Jun 23 18:41:03 PDT 2020
;; MSG SIZE  rcvd: 123

Secondly, Kubernetes has several tools/resources that can help you achieve your hypothetical case. For example, if you'd like to have a single externally available endpoint to pods running in any Kubernetes nodes you can use a Service combined with an Ingress and Ingress Controller.

Related