diff options
author | 2019-08-23 12:54:06 -0400 | |
---|---|---|
committer | 2019-08-23 16:54:06 +0000 | |
commit | 338d148c7845ca4e3a44253ac8b6f040c394b8c4 (patch) | |
tree | 116d758e8a3ec7f8daccda847743e15240890750 /plugin/kubernetes/external.go | |
parent | 84988ce2c20a33a6c37e8136aecb023bad3f17ef (diff) | |
download | coredns-338d148c7845ca4e3a44253ac8b6f040c394b8c4.tar.gz coredns-338d148c7845ca4e3a44253ac8b6f040c394b8c4.tar.zst coredns-338d148c7845ca4e3a44253ac8b6f040c394b8c4.zip |
plugin/k8s_external/kubernetes: handle NS records (#3160)
* fix external ns records
* use k8s service name for ns record
* update test, add func comment
* expand nsAddrs() test cases
* support local ipv6 ip
* use less confusing pod ip in test
Diffstat (limited to 'plugin/kubernetes/external.go')
-rw-r--r-- | plugin/kubernetes/external.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugin/kubernetes/external.go b/plugin/kubernetes/external.go index 4b1104460..42495a430 100644 --- a/plugin/kubernetes/external.go +++ b/plugin/kubernetes/external.go @@ -85,8 +85,10 @@ func (k *Kubernetes) External(state request.Request) ([]msg.Service, int) { // ExternalAddress returns the external service address(es) for the CoreDNS service. func (k *Kubernetes) ExternalAddress(state request.Request) []dns.RR { - // This is probably wrong, because of all the fallback behavior of k.nsAddr, i.e. can get - // an address that isn't reachable from outside the cluster. - rrs := []dns.RR{k.nsAddr()} - return rrs + // If CoreDNS is running inside the Kubernetes cluster: k.nsAddrs() will return the external IPs of the services + // targeting the CoreDNS Pod. + // If CoreDNS is running outside of the Kubernetes cluster: k.nsAddrs() will return the first non-loopback IP + // address seen on the local system it is running on. This could be the wrong answer if coredns is using the *bind* + // plugin to bind to a different IP address. + return k.nsAddrs(true, state.Zone) } |