Corefile is:
example.com {
file db.example.com
debug
lboverlay example.com
forward . 8.8.8.8
}
with db.example.com containing a tiny zone:
example.com. 500 IN SOA ns1.outside.com. root.example.com. 3 604800 86400 2419200 604800
example.com. 500 IN NS ns1.outside.com.
service1.example.com. IN SRV 0 0 8080 host1.example.com.
service1.example.com. IN SRV 0 0 8080 host2.example.com.
service2.example.com. IN SRV 0 0 8082 host3.example.com.
host1.example.com. IN A 127.0.0.1
host2.example.com. IN A 127.0.0.2
host3.example.com. IN A 127.0.0.3
Running coredns with the lboverlay plugin eanbled, and a small util to send HC updates:
% dig -p 1053 @localhost A service1.example.com
;service1.example.com. IN A
;; ANSWER SECTION:
host1.example.com. 500 IN A 127.0.0.1
host2.example.com. 500 IN A 127.0.0.2
Changing the HC (see debug logs below):
;; QUESTION SECTION:
;service1.example.com. IN A
;; ANSWER SECTION:
host2.example.com. 500 IN A 127.0.0.2
;; Query time: 0 msec
;; SERVER: 127.0.0.1#1053(127.0.0.1)
Where CoreDNS logs:
example.com.:1053
CoreDNS-1.8.3
linux/amd64, go1.16.2,
[DEBUG] plugin/overlay: Health status for "host1.example.com.:8080" is: UNKNOWN
[DEBUG] plugin/overlay: Health status for "host2.example.com.:8080" is: UNKNOWN
[DEBUG] plugin/overlay: Found answer for host1.example.com./1, adding 1 record(s)
[DEBUG] plugin/overlay: Found answer for host2.example.com./1, adding 1 record(s)
[DEBUG] plugin/overlay: Health status for "host1.example.com.:8080" set to: UNHEALTHY
[DEBUG] plugin/overlay: Health status for "host1.example.com.:8080" is: UNHEALTHY
[DEBUG] plugin/overlay: Health status for "host2.example.com.:8080" is: UNKNOWN
[DEBUG] plugin/overlay: Found answer for host2.example.com./1, adding 1 record(s)