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:
parent
302434e392
commit
51c05679e6
14 changed files with 204 additions and 111 deletions
|
@ -1,6 +1,7 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin/kubernetes/object"
|
||||
|
@ -21,11 +22,19 @@ func TestDefaultProcessor(t *testing.T) {
|
|||
func testProcessor(t *testing.T, processor cache.ProcessFunc, idx cache.Indexer) {
|
||||
obj := &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "service1", Namespace: "test1"},
|
||||
Spec: api.ServiceSpec{ClusterIP: "1.2.3.4", Ports: []api.ServicePort{{Port: 80}}},
|
||||
Spec: api.ServiceSpec{
|
||||
ClusterIP: "1.2.3.4",
|
||||
ClusterIPs: []string{"1.2.3.4"},
|
||||
Ports: []api.ServicePort{{Port: 80}},
|
||||
},
|
||||
}
|
||||
obj2 := &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "service2", Namespace: "test1"},
|
||||
Spec: api.ServiceSpec{ClusterIP: "5.6.7.8", Ports: []api.ServicePort{{Port: 80}}},
|
||||
Spec: api.ServiceSpec{
|
||||
ClusterIP: "5.6.7.8",
|
||||
ClusterIPs: []string{"5.6.7.8"},
|
||||
Ports: []api.ServicePort{{Port: 80}},
|
||||
},
|
||||
}
|
||||
|
||||
// Add the objects
|
||||
|
@ -47,8 +56,8 @@ func testProcessor(t *testing.T, processor cache.ProcessFunc, idx cache.Indexer)
|
|||
if !ok {
|
||||
t.Fatal("object in index was incorrect type")
|
||||
}
|
||||
if svc.ClusterIP != obj.Spec.ClusterIP {
|
||||
t.Fatalf("expected %v, got %v", obj.Spec.ClusterIP, svc.ClusterIP)
|
||||
if fmt.Sprintf("%v", svc.ClusterIPs) != fmt.Sprintf("%v", obj.Spec.ClusterIPs) {
|
||||
t.Fatalf("expected '%v', got '%v'", obj.Spec.ClusterIPs, svc.ClusterIPs)
|
||||
}
|
||||
|
||||
// Update an object
|
||||
|
@ -71,8 +80,8 @@ func testProcessor(t *testing.T, processor cache.ProcessFunc, idx cache.Indexer)
|
|||
if !ok {
|
||||
t.Fatal("object in index was incorrect type")
|
||||
}
|
||||
if svc.ClusterIP != obj.Spec.ClusterIP {
|
||||
t.Fatalf("expected %v, got %v", obj.Spec.ClusterIP, svc.ClusterIP)
|
||||
if fmt.Sprintf("%v", svc.ClusterIPs) != fmt.Sprintf("%v", obj.Spec.ClusterIPs) {
|
||||
t.Fatalf("expected '%v', got '%v'", obj.Spec.ClusterIPs, svc.ClusterIPs)
|
||||
}
|
||||
|
||||
// Delete an object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue