Do not validate ingresses with unknown ingress class in admission webhook endpoint. (#8221)
This commit is contained in:
parent
d769ceaa5b
commit
04035cc1c2
4 changed files with 42 additions and 0 deletions
|
|
@ -233,6 +233,12 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Do not attempt to validate an ingress that's not meant to be controlled by the current instance of the controller.
|
||||
if ingressClass, err := n.store.GetIngressClass(ing, n.cfg.IngressClassConfiguration); ingressClass == "" {
|
||||
klog.Warningf("ignoring ingress %v in %v based on annotation %v: %v", ing.Name, ing.ObjectMeta.Namespace, ingressClass, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
if n.cfg.Namespace != "" && ing.ObjectMeta.Namespace != n.cfg.Namespace {
|
||||
klog.Warningf("ignoring ingress %v in namespace %v different from the namespace watched %s", ing.Name, ing.ObjectMeta.Namespace, n.cfg.Namespace)
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ type fakeIngressStore struct {
|
|||
configuration ngx_config.Configuration
|
||||
}
|
||||
|
||||
func (fakeIngressStore) GetIngressClass(ing *networking.Ingress, icConfig *ingressclass.IngressClassConfiguration) (string, error) {
|
||||
return "nginx", nil
|
||||
}
|
||||
|
||||
func (fis fakeIngressStore) GetBackendConfiguration() ngx_config.Configuration {
|
||||
return fis.configuration
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ type Storer interface {
|
|||
|
||||
// Run initiates the synchronization of the controllers
|
||||
Run(stopCh chan struct{})
|
||||
|
||||
// GetIngressClass validates given ingress against ingress class configuration and returns the ingress class.
|
||||
GetIngressClass(ing *networkingv1.Ingress, icConfig *ingressclass.IngressClassConfiguration) (string, error)
|
||||
}
|
||||
|
||||
// EventType type of event associated with an informer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue