mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
proxy/iptables: don't proxy ExternalName services
The API docs say: // ServiceTypeExternalName means a service consists of only a reference to // an external name that kubedns or equivalent will return as a CNAME // record, with no exposing or proxying of any pods involved. which implies that ExternalName services should be ignored for proxy purposes.
This commit is contained in:
parent
eae2b8e9ba
commit
433f6830f8
@ -471,6 +471,11 @@ func buildServiceMap(allServices []api.Service, oldServiceMap proxyServiceMap) (
|
|||||||
glog.V(3).Infof("Skipping service %s due to clusterIP = %q", svcName, service.Spec.ClusterIP)
|
glog.V(3).Infof("Skipping service %s due to clusterIP = %q", svcName, service.Spec.ClusterIP)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Even if ClusterIP is set, ServiceTypeExternalName services don't get proxied
|
||||||
|
if service.Spec.Type == api.ServiceTypeExternalName {
|
||||||
|
glog.V(3).Infof("Skipping service %s due to Type=ExternalName", svcName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for i := range service.Spec.Ports {
|
for i := range service.Spec.Ports {
|
||||||
servicePort := &service.Spec.Ports[i]
|
servicePort := &service.Spec.Ports[i]
|
||||||
|
@ -1053,4 +1053,30 @@ func TestBuildServiceMapServiceHeadless(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildServiceMapServiceTypeExternalName(t *testing.T) {
|
||||||
|
services := []api.Service{
|
||||||
|
makeTestService("somewhere-else", "external-name", func(svc *api.Service) {
|
||||||
|
svc.Spec.Type = api.ServiceTypeExternalName
|
||||||
|
svc.Spec.ClusterIP = "172.16.55.4" // Should be ignored
|
||||||
|
svc.Spec.ExternalName = "foo2.bar.com"
|
||||||
|
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "blah", "UDP", 1235, 5321, 0)
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
serviceMap, hcAdd, hcDel, staleUDPServices := buildServiceMap(services, make(proxyServiceMap))
|
||||||
|
if len(serviceMap) != 0 {
|
||||||
|
t.Errorf("expected service map length 0, got %v", serviceMap)
|
||||||
|
}
|
||||||
|
// No proxied services, so no healthchecks
|
||||||
|
if len(hcAdd) != 0 {
|
||||||
|
t.Errorf("expected healthcheck add length 0, got %v", hcAdd)
|
||||||
|
}
|
||||||
|
if len(hcDel) != 0 {
|
||||||
|
t.Errorf("expected healthcheck del length 0, got %v", hcDel)
|
||||||
|
}
|
||||||
|
if len(staleUDPServices) != 0 {
|
||||||
|
t.Errorf("expected stale UDP services length 0, got %v", staleUDPServices)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(thockin): add *more* tests for syncProxyRules() or break it down further and test the pieces.
|
// TODO(thockin): add *more* tests for syncProxyRules() or break it down further and test the pieces.
|
||||||
|
Loading…
Reference in New Issue
Block a user