Allow service type ExternalName with different port and targetPort (#5141)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-02-20 23:06:05 -03:00 committed by GitHub
parent 7d52174b51
commit cd94ac7f84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 30 deletions

View file

@ -50,13 +50,7 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
// ExternalName services
if s.Spec.Type == corev1.ServiceTypeExternalName {
klog.V(3).Infof("Ingress using Service %q of type ExternalName.", svcKey)
targetPort := port.TargetPort.IntValue()
if targetPort <= 0 {
klog.Errorf("ExternalName Service %q has an invalid port (%v)", svcKey, targetPort)
return upsServers
}
// if the externalName is not an IP address we need to validate is a valid FQDN
if net.ParseIP(s.Spec.ExternalName) == nil {
if errs := validation.IsDNS1123Subdomain(s.Spec.ExternalName); len(errs) > 0 {