Mapping FQDN to IP and Port number in HAProxy
I have HAproxy in front of my K8s cluster. It works perfectly by IP address and port number.
frontend kubernetes-test-frontend
bind 10.138.1.187:30030
mode tcp
option tcplog
default_backend kubernetes-test-backend
backend kubernetes-test-backend
mode tcp
option tcp-check
balance roundrobin
server k8master1 10.138.1.181:30030 check
server k8master2 10.138.1.182:30030 check
server k8node1 10.138.1.183:30030 check
server k8node2 10.138.1.184:30030 check
server k8node3 10.138.1.185:30030 check
Can I have FQDN to replace IP and port number? For example, if I have www.test.com mapping to 10.138.1.187 in my internal DNS. Can I set up HAproxy to map www.test.com/test to node's IP:30030?
You can switch from using an IP address to using DNS - but read the documentation for your version of HAProxy to understand the potential trade-offs.
If you switch to DNS lookups for your backend servers you will still need to define their listening port in your backend configuration.