Fix no endpoints issue when named ports are used
This commit is contained in:
parent
72f484e72f
commit
a970ef834d
1 changed files with 17 additions and 13 deletions
|
@ -836,20 +836,24 @@ func (ic *GenericController) serviceEndpoints(svcKey, backendPort string,
|
||||||
svc := svcObj.(*api.Service)
|
svc := svcObj.(*api.Service)
|
||||||
glog.V(3).Infof("obtaining port information for service %v", svcKey)
|
glog.V(3).Infof("obtaining port information for service %v", svcKey)
|
||||||
for _, servicePort := range svc.Spec.Ports {
|
for _, servicePort := range svc.Spec.Ports {
|
||||||
// targetPort could be a string, use the name or the port (int)
|
var p intstr.IntOrString
|
||||||
if strconv.Itoa(int(servicePort.Port)) == backendPort ||
|
switch {
|
||||||
servicePort.TargetPort.String() == backendPort ||
|
case backendPort == strconv.Itoa(int(servicePort.Port)):
|
||||||
servicePort.Name == backendPort {
|
p = intstr.FromInt(int(servicePort.Port))
|
||||||
|
case backendPort == servicePort.Name:
|
||||||
endps := ic.getEndpoints(svc, servicePort.TargetPort, api.ProtocolTCP, hz)
|
p = intstr.FromString(servicePort.Name)
|
||||||
if len(endps) == 0 {
|
default:
|
||||||
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(ingress.EndpointByAddrPort(endps))
|
|
||||||
upstreams = append(upstreams, endps...)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endps := ic.getEndpoints(svc, p, api.ProtocolTCP, hz)
|
||||||
|
if len(endps) == 0 {
|
||||||
|
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(ingress.EndpointByAddrPort(endps))
|
||||||
|
upstreams = append(upstreams, endps...)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
return upstreams, nil
|
return upstreams, nil
|
||||||
|
|
Loading…
Reference in a new issue