aggregation: add ExternalName service support
Kubernetes-commit: 8b409e8f777a305454616554c40c905acad596ac
This commit is contained in:
parent
6b536dfda4
commit
a3e36a6bf1
|
|
@ -113,6 +113,14 @@ func ResolveCluster(services listersv1.ServiceLister, namespace, id string) (*ur
|
||||||
Scheme: "https",
|
Scheme: "https",
|
||||||
Host: net.JoinHostPort(svc.Spec.ClusterIP, fmt.Sprintf("%d", svcPort.Port)),
|
Host: net.JoinHostPort(svc.Spec.ClusterIP, fmt.Sprintf("%d", svcPort.Port)),
|
||||||
}, nil
|
}, nil
|
||||||
|
case svc.Spec.Type == v1.ServiceTypeExternalName:
|
||||||
|
if port.Type != intstr.Int {
|
||||||
|
return nil, fmt.Errorf("named ports not supported")
|
||||||
|
}
|
||||||
|
return &url.URL{
|
||||||
|
Scheme: "https",
|
||||||
|
Host: net.JoinHostPort(svc.Spec.ExternalName, port.String()),
|
||||||
|
}, nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported service type %q", svc.Spec.Type)
|
return nil, fmt.Errorf("unsupported service type %q", svc.Spec.Type)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,22 @@ func TestResolve(t *testing.T) {
|
||||||
clusterMode: expectation{url: "https://np:443"},
|
clusterMode: expectation{url: "https://np:443"},
|
||||||
endpointMode: expectation{url: "https://127.0.0.1:1443"},
|
endpointMode: expectation{url: "https://127.0.0.1:1443"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "external name",
|
||||||
|
services: []*v1.Service{
|
||||||
|
{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "one", Name: "alfa"},
|
||||||
|
Spec: v1.ServiceSpec{
|
||||||
|
Type: v1.ServiceTypeExternalName,
|
||||||
|
ExternalName: "foo.bar.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints: nil,
|
||||||
|
|
||||||
|
clusterMode: expectation{url: "https://foo.bar.com:443"},
|
||||||
|
endpointMode: expectation{error: true},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "missing service",
|
name: "missing service",
|
||||||
services: nil,
|
services: nil,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue