plugin/kubernetes: Handle multiple local IPs and bind (#3208)

* use all local IPs

* mult/bind ips

* gofmt + boundIPs fix

* fix no matching endpoint case

* don't duplicate NS records in answer

* fix answer dedup

* fix comment

* add multi local ip test case
This commit is contained in:
Chris O'Haver
2019-09-05 09:07:55 -04:00
committed by GitHub
parent d79562842a
commit 630d3d60b9
8 changed files with 91 additions and 51 deletions

View File

@@ -372,6 +372,8 @@ func NS(ctx context.Context, b ServiceBackend, zone string, state request.Reques
// ... and reset
state.Req.Question[0].Name = old
seen := map[string]bool{}
for _, serv := range services {
what, ip := serv.HostType()
switch what {
@@ -380,8 +382,13 @@ func NS(ctx context.Context, b ServiceBackend, zone string, state request.Reques
case dns.TypeA, dns.TypeAAAA:
serv.Host = msg.Domain(serv.Key)
records = append(records, serv.NewNS(state.QName()))
extra = append(extra, newAddress(serv, serv.Host, ip, what))
ns := serv.NewNS(state.QName())
if _, ok := seen[ns.Ns]; ok {
continue
}
seen[ns.Ns] = true
records = append(records, ns)
}
}
return records, extra, nil