diff options
Diffstat (limited to 'plugin/k8s_external/msg_to_dns.go')
-rw-r--r-- | plugin/k8s_external/msg_to_dns.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugin/k8s_external/msg_to_dns.go b/plugin/k8s_external/msg_to_dns.go index d09229d48..14a198063 100644 --- a/plugin/k8s_external/msg_to_dns.go +++ b/plugin/k8s_external/msg_to_dns.go @@ -1,6 +1,7 @@ package external import ( + "context" "math" "github.com/coredns/coredns/plugin/etcd/msg" @@ -9,7 +10,7 @@ import ( "github.com/miekg/dns" ) -func (e *External) a(services []msg.Service, state request.Request) (records []dns.RR) { +func (e *External) a(ctx context.Context, services []msg.Service, state request.Request) (records []dns.RR) { dup := make(map[string]struct{}) for _, s := range services { @@ -18,7 +19,13 @@ func (e *External) a(services []msg.Service, state request.Request) (records []d switch what { case dns.TypeCNAME: - // can't happen + rr := s.NewCNAME(state.QName(), s.Host) + records = append(records, rr) + if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeA); err == nil { + for _, rr := range resp.Answer { + records = append(records, rr) + } + } case dns.TypeA: if _, ok := dup[s.Host]; !ok { @@ -35,7 +42,7 @@ func (e *External) a(services []msg.Service, state request.Request) (records []d return records } -func (e *External) aaaa(services []msg.Service, state request.Request) (records []dns.RR) { +func (e *External) aaaa(ctx context.Context, services []msg.Service, state request.Request) (records []dns.RR) { dup := make(map[string]struct{}) for _, s := range services { @@ -44,7 +51,13 @@ func (e *External) aaaa(services []msg.Service, state request.Request) (records switch what { case dns.TypeCNAME: - // can't happen + rr := s.NewCNAME(state.QName(), s.Host) + records = append(records, rr) + if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeAAAA); err == nil { + for _, rr := range resp.Answer { + records = append(records, rr) + } + } case dns.TypeA: // nada |