mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
only create PTR records for endpoints with hostname defined (#6898)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -44,8 +44,13 @@ func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
|
||||
}
|
||||
for _, eps := range ep.Subsets {
|
||||
for _, addr := range eps.Addresses {
|
||||
if addr.IP == ip {
|
||||
domain := strings.Join([]string{endpointHostname(addr, k.endpointNameMode), ep.Index, Svc, k.primaryZone()}, ".")
|
||||
// The endpoint's Hostname will be set if this endpoint is supposed to generate a PTR.
|
||||
// So only return reverse records that match the IP AND have a non-empty hostname.
|
||||
// Kubernetes more or less keeps this to one canonical service/endpoint per IP, but in the odd event there
|
||||
// are multiple endpoints for the same IP with hostname set, return them all rather than selecting one
|
||||
// arbitrarily.
|
||||
if addr.IP == ip && addr.Hostname != "" {
|
||||
domain := strings.Join([]string{addr.Hostname, ep.Index, Svc, k.primaryZone()}, ".")
|
||||
svcs = append(svcs, msg.Service{Host: domain, TTL: k.ttl})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user