Skip to content

wcurrie/spring-cloud-dns-srv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What

An experimental implementation of spring cloud's LoadBalancerClient that uses DNS SRV records.

Test

Run a local dnsmasq instance configured with 2 SRV records for web.service.local. One resolving to google.com. Another to slashdot.org.

docker run --rm --name dnsmasq -p 53:53/udp -p 8081:8080 -v $PWD/dnsmasq.conf:/etc/dnsmasq.conf quay.io/jpillora/dnsmasq-gui:latest

Seems dnsmasq will round robin between these 2 records. Run dig a few times to see:

dig @localhost web.service.local SRV +short

Run the silly little app containing DnsSrvLoadBalancerClient.

run Application

Test using curl (or your browser).

curl localhost:8080/

Where Does the spring magic happen?

Spring boot's LoadBalancerAutoConfiguration adds a LoadBalancerInterceptor that will rewrite a GET request to https://web.service.local to one of the hosts resolved from a DNS lookup (google.com or slashdot.org).

About

Load balance using DNS SRV records

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages