aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/local.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2019-08-23 12:54:06 -0400
committerGravatar Miek Gieben <miek@miek.nl> 2019-08-23 16:54:06 +0000
commit338d148c7845ca4e3a44253ac8b6f040c394b8c4 (patch)
tree116d758e8a3ec7f8daccda847743e15240890750 /plugin/kubernetes/local.go
parent84988ce2c20a33a6c37e8136aecb023bad3f17ef (diff)
downloadcoredns-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/local.go')
-rw-r--r--plugin/kubernetes/local.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugin/kubernetes/local.go b/plugin/kubernetes/local.go
index c5918a306..199af6f0d 100644
--- a/plugin/kubernetes/local.go
+++ b/plugin/kubernetes/local.go
@@ -12,11 +12,14 @@ func localPodIP() net.IP {
for _, addr := range addrs {
ip, _, _ := net.ParseCIDR(addr.String())
- ip = ip.To4()
- if ip == nil || ip.IsLoopback() {
- continue
+ ip4 := ip.To4()
+ if ip4 != nil && !ip4.IsLoopback() {
+ return ip4
+ }
+ ip6 := ip.To16()
+ if ip6 != nil && !ip6.IsLoopback() {
+ return ip6
}
- return ip
}
return nil
}