return all records with matching ip (#3687)

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver 2020-02-21 01:24:02 -05:00 committed by GitHub
parent ed1841c36f
commit 6ef105ced3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 26 deletions

View file

@ -38,6 +38,7 @@ func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
return []msg.Service{{Host: domain, TTL: k.ttl}}
}
// If no cluster ips match, search endpoints
var svcs []msg.Service
for _, ep := range k.APIConn.EpIndexReverse(ip) {
if len(k.Namespaces) > 0 && !k.namespaceExposed(ep.Namespace) {
continue
@ -46,10 +47,10 @@ func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
for _, addr := range eps.Addresses {
if addr.IP == ip {
domain := strings.Join([]string{endpointHostname(addr, k.endpointNameMode), ep.Name, ep.Namespace, Svc, k.primaryZone()}, ".")
return []msg.Service{{Host: domain, TTL: k.ttl}}
svcs = append(svcs, msg.Service{Host: domain, TTL: k.ttl})
}
}
}
}
return nil
return svcs
}