mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
plugin/k8s: Use service IP index in reverse lookups (#1212)
* use index for svc reverse lookup * temp revert * restore reverse.go * restore reverse_test.go
This commit is contained in:
committed by
Miek Gieben
parent
beef212fbe
commit
a78f46fb28
@@ -25,14 +25,12 @@ func (k *Kubernetes) Reverse(state request.Request, exact bool, opt plugin.Optio
|
||||
// If a service cluster ip does not match, it checks all endpoints
|
||||
func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service {
|
||||
// First check services with cluster ips
|
||||
for _, service := range k.APIConn.ServiceList() {
|
||||
for _, service := range k.APIConn.SvcIndexReverse(ip) {
|
||||
if (len(k.Namespaces) > 0) && !k.namespaceExposed(service.Namespace) {
|
||||
continue
|
||||
}
|
||||
if service.Spec.ClusterIP == ip {
|
||||
domain := strings.Join([]string{service.Name, service.Namespace, Svc, k.primaryZone()}, ".")
|
||||
return []msg.Service{{Host: domain}}
|
||||
}
|
||||
domain := strings.Join([]string{service.Name, service.Namespace, Svc, k.primaryZone()}, ".")
|
||||
return []msg.Service{{Host: domain}}
|
||||
}
|
||||
// If no cluster ips match, search endpoints
|
||||
for _, ep := range k.APIConn.EpIndexReverse(ip) {
|
||||
|
||||
Reference in New Issue
Block a user