aggregation: handle ClusterIPNone correctly

This commit is contained in:
Dr. Stefan Schimanski 2017-05-30 10:58:33 +02:00
parent d56759452c
commit b1f708758c
2 changed files with 18 additions and 0 deletions

View File

@ -101,6 +101,8 @@ func ResolveCluster(services listersv1.ServiceLister, namespace, id string) (*ur
port := intstr.FromInt(443)
switch {
case svc.Spec.Type == v1.ServiceTypeClusterIP && svc.Spec.ClusterIP == v1.ClusterIPNone:
return nil, fmt.Errorf(`cannot route to service with ClusterIP "None"`)
// use IP from a clusterIP for these service types
case svc.Spec.Type == v1.ServiceTypeClusterIP, svc.Spec.Type == v1.ServiceTypeLoadBalancer, svc.Spec.Type == v1.ServiceTypeNodePort:
svcPort, err := findServicePort(svc, port)

View File

@ -118,6 +118,22 @@ func TestResolve(t *testing.T) {
clusterMode: expectation{url: "https://hit:443"},
endpointMode: expectation{error: true},
},
{
name: "none cluster ip",
services: []*v1.Service{
{
ObjectMeta: metav1.ObjectMeta{Namespace: "one", Name: "alfa"},
Spec: v1.ServiceSpec{
Type: v1.ServiceTypeClusterIP,
ClusterIP: v1.ClusterIPNone,
},
},
},
endpoints: nil,
clusterMode: expectation{error: true},
endpointMode: expectation{error: true},
},
{
name: "loadbalancer",
services: []*v1.Service{