mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
plugin/kubernetes: Add support for dual stack ClusterIP Services (#4339)
* support dual stack clusterIPs Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * stickler Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix ClusterIPs make Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
api "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func isDefaultNS(name, zone string) bool {
|
||||
@@ -37,7 +36,7 @@ func (k *Kubernetes) nsAddrs(external bool, zone string) []dns.RR {
|
||||
continue
|
||||
}
|
||||
svcName := strings.Join([]string{svc.Name, svc.Namespace, Svc, zone}, ".")
|
||||
if svc.ClusterIP == api.ClusterIPNone {
|
||||
if svc.Headless() {
|
||||
// For a headless service, use the endpoints IPs
|
||||
for _, s := range endpoint.Subsets {
|
||||
for _, a := range s.Addresses {
|
||||
@@ -46,8 +45,10 @@ func (k *Kubernetes) nsAddrs(external bool, zone string) []dns.RR {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
svcNames = append(svcNames, svcName)
|
||||
svcIPs = append(svcIPs, net.ParseIP(svc.ClusterIP))
|
||||
for _, clusterIP := range svc.ClusterIPs {
|
||||
svcNames = append(svcNames, svcName)
|
||||
svcIPs = append(svcIPs, net.ParseIP(clusterIP))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user