mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user