diff options
Diffstat (limited to 'plugin/kubernetes/ns.go')
-rw-r--r-- | plugin/kubernetes/ns.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/plugin/kubernetes/ns.go b/plugin/kubernetes/ns.go index 4774e176f..f21890cc9 100644 --- a/plugin/kubernetes/ns.go +++ b/plugin/kubernetes/ns.go @@ -21,15 +21,10 @@ func (k *Kubernetes) nsAddrs(external bool, zone string) []dns.RR { svcIPs []net.IP ) - // Find the CoreDNS Endpoint - localIP := k.interfaceAddrsFunc() - endpoints := k.APIConn.EpIndexReverse(localIP.String()) + // Find the CoreDNS Endpoints + for _, localIP := range k.localIPs { + endpoints := k.APIConn.EpIndexReverse(localIP.String()) - // If the CoreDNS Endpoint is not found, use the locally bound IP address - if len(endpoints) == 0 { - svcNames = []string{defaultNSName + zone} - svcIPs = []net.IP{localIP} - } else { // Collect IPs for all Services of the Endpoints for _, endpoint := range endpoints { svcs := k.APIConn.SvcIndex(object.ServiceKey(endpoint.Name, endpoint.Namespace)) @@ -59,6 +54,16 @@ func (k *Kubernetes) nsAddrs(external bool, zone string) []dns.RR { } } + // If no local IPs matched any endpoints, use the localIPs directly + if len(svcIPs) == 0 { + svcIPs = make([]net.IP, len(k.localIPs)) + svcNames = make([]string, len(k.localIPs)) + for i, localIP := range k.localIPs { + svcNames[i] = defaultNSName + zone + svcIPs[i] = localIP + } + } + // Create an RR slice of collected IPs var rrs []dns.RR rrs = make([]dns.RR, len(svcIPs)) |