Revert "only create PTR records for endpoints with hostname defined (#6898)" (#7194)

This reverts commit f4f0d55dce.

Signed-off-by: Adrian Moisey <adrian@changeover.za.net>
This commit is contained in:
Adrian Moisey
2025-03-18 21:42:43 +02:00
committed by GitHub
parent 4de8fb57b2
commit 58d8999192
2 changed files with 15 additions and 21 deletions

View File

@@ -44,13 +44,8 @@ func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
}
for _, eps := range ep.Subsets {
for _, addr := range eps.Addresses {
// 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()}, ".")
if addr.IP == ip {
domain := strings.Join([]string{endpointHostname(addr, k.endpointNameMode), ep.Index, Svc, k.primaryZone()}, ".")
svcs = append(svcs, msg.Service{Host: domain, TTL: k.ttl})
}
}