Merge pull request #629 from aledbf/externalname-feature
Add support for services of type ExternalName
This commit is contained in:
commit
b18f8e86ad
1 changed files with 47 additions and 6 deletions
|
@ -1024,12 +1024,6 @@ func (ic *GenericController) getEndpoints(
|
||||||
servicePort intstr.IntOrString,
|
servicePort intstr.IntOrString,
|
||||||
proto api.Protocol,
|
proto api.Protocol,
|
||||||
hz *healthcheck.Upstream) []ingress.Endpoint {
|
hz *healthcheck.Upstream) []ingress.Endpoint {
|
||||||
glog.V(3).Infof("getting endpoints for service %v/%v and port %v", s.Namespace, s.Name, servicePort.String())
|
|
||||||
ep, err := ic.endpLister.GetServiceEndpoints(s)
|
|
||||||
if err != nil {
|
|
||||||
glog.Warningf("unexpected error obtaining service endpoints: %v", err)
|
|
||||||
return []ingress.Endpoint{}
|
|
||||||
}
|
|
||||||
|
|
||||||
upsServers := []ingress.Endpoint{}
|
upsServers := []ingress.Endpoint{}
|
||||||
|
|
||||||
|
@ -1038,6 +1032,53 @@ func (ic *GenericController) getEndpoints(
|
||||||
// targetport.
|
// targetport.
|
||||||
adus := make(map[string]bool, 0)
|
adus := make(map[string]bool, 0)
|
||||||
|
|
||||||
|
// ExternalName services
|
||||||
|
if s.Spec.Type == api.ServiceTypeExternalName {
|
||||||
|
var targetPort int
|
||||||
|
|
||||||
|
switch servicePort.Type {
|
||||||
|
case intstr.Int:
|
||||||
|
targetPort = servicePort.IntValue()
|
||||||
|
case intstr.String:
|
||||||
|
port, err := service.GetPortMapping(servicePort.StrVal, s)
|
||||||
|
if err == nil {
|
||||||
|
targetPort = int(port)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.Warningf("error mapping service port: %v", err)
|
||||||
|
err = ic.checkSvcForUpdate(s)
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("error mapping service ports: %v", err)
|
||||||
|
return upsServers
|
||||||
|
}
|
||||||
|
|
||||||
|
port, err = service.GetPortMapping(servicePort.StrVal, s)
|
||||||
|
if err == nil {
|
||||||
|
targetPort = int(port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for invalid port value
|
||||||
|
if targetPort <= 0 {
|
||||||
|
return upsServers
|
||||||
|
}
|
||||||
|
|
||||||
|
return append(upsServers, ingress.Endpoint{
|
||||||
|
Address: s.Spec.ExternalName,
|
||||||
|
Port: fmt.Sprintf("%v", targetPort),
|
||||||
|
MaxFails: hz.MaxFails,
|
||||||
|
FailTimeout: hz.FailTimeout,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(3).Infof("getting endpoints for service %v/%v and port %v", s.Namespace, s.Name, servicePort.String())
|
||||||
|
ep, err := ic.endpLister.GetServiceEndpoints(s)
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("unexpected error obtaining service endpoints: %v", err)
|
||||||
|
return upsServers
|
||||||
|
}
|
||||||
|
|
||||||
for _, ss := range ep.Subsets {
|
for _, ss := range ep.Subsets {
|
||||||
for _, epPort := range ss.Ports {
|
for _, epPort := range ss.Ports {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue