0

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?

4
  • 1
    You can’t have FQDN map to IP address and port number.  You should be able to have FQDN map to IP address; but FQDN doesn’t map to port number.  Have you tried www.test.com:30030? … … … … … … … … … … … … … … … … … P.S.  Your config file excerpt uses port number 30030, but your question mentions port number 30090. Jun 7, 2021 at 1:12
  • 1
    Doesn't haproxy have an other mode than TCP? Jun 7, 2021 at 4:19
  • @Scott Sorry for the typo:)
    – ITnewbie
    Jun 7, 2021 at 4:27
  • 1
    @Gerard H. Pille, HAProxy can work in http mode or in tcp mode, and HAProxy can use DNS to lookup server names, but you still need to define the listening port. haproxy.com/documentation/hapee/latest/configuration/…
    – Mikael H
    Jun 7, 2021 at 5:39

1 Answer 1

1

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.

1
  • Thank you so much! Just like you mentioned, I solved the problem by using http mode and ACL in the HAProxy configuration
    – ITnewbie
    Jul 21, 2021 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.