@@ -1024,12 +1024,6 @@ func (ic *GenericController) getEndpoints(
1024
1024
servicePort intstr.IntOrString ,
1025
1025
proto api.Protocol ,
1026
1026
hz * healthcheck.Upstream ) []ingress.Endpoint {
1027
- glog .V (3 ).Infof ("getting endpoints for service %v/%v and port %v" , s .Namespace , s .Name , servicePort .String ())
1028
- ep , err := ic .endpLister .GetServiceEndpoints (s )
1029
- if err != nil {
1030
- glog .Warningf ("unexpected error obtaining service endpoints: %v" , err )
1031
- return []ingress.Endpoint {}
1032
- }
1033
1027
1034
1028
upsServers := []ingress.Endpoint {}
1035
1029
@@ -1038,6 +1032,53 @@ func (ic *GenericController) getEndpoints(
1038
1032
// targetport.
1039
1033
adus := make (map [string ]bool , 0 )
1040
1034
1035
+ // ExternalName services
1036
+ if s .Spec .Type == api .ServiceTypeExternalName {
1037
+ var targetPort int
1038
+
1039
+ switch servicePort .Type {
1040
+ case intstr .Int :
1041
+ targetPort = servicePort .IntValue ()
1042
+ case intstr .String :
1043
+ port , err := service .GetPortMapping (servicePort .StrVal , s )
1044
+ if err == nil {
1045
+ targetPort = int (port )
1046
+ break
1047
+ }
1048
+
1049
+ glog .Warningf ("error mapping service port: %v" , err )
1050
+ err = ic .checkSvcForUpdate (s )
1051
+ if err != nil {
1052
+ glog .Warningf ("error mapping service ports: %v" , err )
1053
+ return upsServers
1054
+ }
1055
+
1056
+ port , err = service .GetPortMapping (servicePort .StrVal , s )
1057
+ if err == nil {
1058
+ targetPort = int (port )
1059
+ }
1060
+ }
1061
+
1062
+ // check for invalid port value
1063
+ if targetPort <= 0 {
1064
+ return upsServers
1065
+ }
1066
+
1067
+ return append (upsServers , ingress.Endpoint {
1068
+ Address : s .Spec .ExternalName ,
1069
+ Port : fmt .Sprintf ("%v" , targetPort ),
1070
+ MaxFails : hz .MaxFails ,
1071
+ FailTimeout : hz .FailTimeout ,
1072
+ })
1073
+ }
1074
+
1075
+ glog .V (3 ).Infof ("getting endpoints for service %v/%v and port %v" , s .Namespace , s .Name , servicePort .String ())
1076
+ ep , err := ic .endpLister .GetServiceEndpoints (s )
1077
+ if err != nil {
1078
+ glog .Warningf ("unexpected error obtaining service endpoints: %v" , err )
1079
+ return upsServers
1080
+ }
1081
+
1041
1082
for _ , ss := range ep .Subsets {
1042
1083
for _ , epPort := range ss .Ports {
1043
1084
0 commit comments