[Cherry Pick] - Add configuration to disable external name service feature (#7314) (#7321)

* Add configuration to disable external name service feature (#7314)

Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>

* Fix CI files
This commit is contained in:
Ricardo Katz 2021-07-06 01:50:18 -03:00 committed by GitHub
parent a8408cdb51
commit f5c80783bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 144 additions and 105 deletions

View file

@ -85,6 +85,8 @@ type Configuration struct {
ListenPorts *ngx_config.ListenPorts
DisableServiceExternalName bool
EnableSSLPassthrough bool
EnableProfiling bool
@ -963,6 +965,10 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
// Ingress with an ExternalName Service and no port defined for that Service
if svc.Spec.Type == apiv1.ServiceTypeExternalName {
if n.cfg.DisableServiceExternalName {
klog.Warningf("Service %q of type ExternalName not allowed due to Ingress configuration.", svcKey)
return upstreams, nil
}
servicePort := externalNamePorts(backendPort, svc)
endps := getEndpoints(svc, servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
if len(endps) == 0 {