aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/handler_test.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2020-12-21 05:30:24 -0500
committerGravatar GitHub <noreply@github.com> 2020-12-21 02:30:24 -0800
commit51c05679e69dacd745db2b1eb33be04d7b626959 (patch)
tree6ec0071b8378f31a0d96eeea4061e58723be2d6d /plugin/kubernetes/handler_test.go
parent302434e3928219138313610c7faf9be5cc598129 (diff)
downloadcoredns-51c05679e69dacd745db2b1eb33be04d7b626959.tar.gz
coredns-51c05679e69dacd745db2b1eb33be04d7b626959.tar.zst
coredns-51c05679e69dacd745db2b1eb33be04d7b626959.zip
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>
Diffstat (limited to 'plugin/kubernetes/handler_test.go')
-rw-r--r--plugin/kubernetes/handler_test.go82
1 files changed, 58 insertions, 24 deletions
diff --git a/plugin/kubernetes/handler_test.go b/plugin/kubernetes/handler_test.go
index f5630ccdd..71609a6de 100644
--- a/plugin/kubernetes/handler_test.go
+++ b/plugin/kubernetes/handler_test.go
@@ -372,6 +372,30 @@ var dnsTestCases = []test.Case{
test.SOA("cluster.local. 5 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 5"),
},
},
+ // Dual Stack ClusterIP Services
+ {
+ Qname: "svc-dual-stack.testns.svc.cluster.local.", Qtype: dns.TypeA,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.A("svc-dual-stack.testns.svc.cluster.local. 5 IN A 10.0.0.3"),
+ },
+ },
+ {
+ Qname: "svc-dual-stack.testns.svc.cluster.local.", Qtype: dns.TypeAAAA,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.AAAA("svc-dual-stack.testns.svc.cluster.local. 5 IN AAAA 10::3"),
+ },
+ },
+ {
+ Qname: "svc-dual-stack.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{test.SRV("svc-dual-stack.testns.svc.cluster.local. 5 IN SRV 0 50 80 svc-dual-stack.testns.svc.cluster.local.")},
+ Extra: []dns.RR{
+ test.A("svc-dual-stack.testns.svc.cluster.local. 5 IN A 10.0.0.3"),
+ test.AAAA("svc-dual-stack.testns.svc.cluster.local. 5 IN AAAA 10::3"),
+ },
+ },
}
func TestServeDNS(t *testing.T) {
@@ -539,10 +563,10 @@ func (APIConnServeTest) PodIndex(ip string) []*object.Pod {
var svcIndex = map[string][]*object.Service{
"svc1.testns": {
{
- Name: "svc1",
- Namespace: "testns",
- Type: api.ServiceTypeClusterIP,
- ClusterIP: "10.0.0.1",
+ Name: "svc1",
+ Namespace: "testns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{"10.0.0.1"},
Ports: []api.ServicePort{
{Name: "http", Protocol: "tcp", Port: 80},
},
@@ -550,10 +574,10 @@ var svcIndex = map[string][]*object.Service{
},
"svcempty.testns": {
{
- Name: "svcempty",
- Namespace: "testns",
- Type: api.ServiceTypeClusterIP,
- ClusterIP: "10.0.0.1",
+ Name: "svcempty",
+ Namespace: "testns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{"10.0.0.1"},
Ports: []api.ServicePort{
{Name: "http", Protocol: "tcp", Port: 80},
},
@@ -561,10 +585,10 @@ var svcIndex = map[string][]*object.Service{
},
"svc6.testns": {
{
- Name: "svc6",
- Namespace: "testns",
- Type: api.ServiceTypeClusterIP,
- ClusterIP: "1234:abcd::1",
+ Name: "svc6",
+ Namespace: "testns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{"1234:abcd::1"},
Ports: []api.ServicePort{
{Name: "http", Protocol: "tcp", Port: 80},
},
@@ -572,10 +596,10 @@ var svcIndex = map[string][]*object.Service{
},
"hdls1.testns": {
{
- Name: "hdls1",
- Namespace: "testns",
- Type: api.ServiceTypeClusterIP,
- ClusterIP: api.ClusterIPNone,
+ Name: "hdls1",
+ Namespace: "testns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{api.ClusterIPNone},
},
},
"external.testns": {
@@ -602,23 +626,33 @@ var svcIndex = map[string][]*object.Service{
},
"hdlsprtls.testns": {
{
- Name: "hdlsprtls",
- Namespace: "testns",
- Type: api.ServiceTypeClusterIP,
- ClusterIP: api.ClusterIPNone,
+ Name: "hdlsprtls",
+ Namespace: "testns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{api.ClusterIPNone},
},
},
"svc1.unexposedns": {
{
- Name: "svc1",
- Namespace: "unexposedns",
- Type: api.ServiceTypeClusterIP,
- ClusterIP: "10.0.0.2",
+ Name: "svc1",
+ Namespace: "unexposedns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{"10.0.0.2"},
Ports: []api.ServicePort{
{Name: "http", Protocol: "tcp", Port: 80},
},
},
},
+ "svc-dual-stack.testns": {
+ {
+ Name: "svc-dual-stack",
+ Namespace: "testns",
+ Type: api.ServiceTypeClusterIP,
+ ClusterIPs: []string{"10.0.0.3", "10::3"}, Ports: []api.ServicePort{
+ {Name: "http", Protocol: "tcp", Port: 80},
+ },
+ },
+ },
}
func (APIConnServeTest) SvcIndex(s string) []*object.Service { return svcIndex[s] }