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

Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>
This commit is contained in:
Ricardo Katz 2021-07-04 17:24:19 -03:00 committed by GitHub
parent 16072ac690
commit bc220f7366
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 136 additions and 23 deletions

View file

@ -85,6 +85,8 @@ type Configuration struct {
ListenPorts *ngx_config.ListenPorts
DisableServiceExternalName bool
EnableSSLPassthrough bool
EnableProfiling bool
@ -968,6 +970,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 {