mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
aggregation: add ExternalName service support
This commit is contained in:
parent
b1f708758c
commit
8b409e8f77
@ -113,6 +113,14 @@ func ResolveCluster(services listersv1.ServiceLister, namespace, id string) (*ur
|
||||
Scheme: "https",
|
||||
Host: net.JoinHostPort(svc.Spec.ClusterIP, fmt.Sprintf("%d", svcPort.Port)),
|
||||
}, 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:
|
||||
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"},
|
||||
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",
|
||||
services: nil,
|
||||
|
Loading…
Reference in New Issue
Block a user