diff --git a/internal/ingress/annotations/class/main.go b/internal/ingress/annotations/class/main.go index 812c63d91..6b5a6d06c 100644 --- a/internal/ingress/annotations/class/main.go +++ b/internal/ingress/annotations/class/main.go @@ -35,7 +35,7 @@ var ( // IngressClass sets the runtime ingress class to use // An empty string means accept all ingresses without // annotation and the ones configured with class nginx - IngressClass = "" + IngressClass = "nginx" ) // IsValid returns true if the given Ingress either doesn't specify diff --git a/internal/ingress/annotations/class/main_test.go b/internal/ingress/annotations/class/main_test.go index bb8d2db65..8b85e3192 100644 --- a/internal/ingress/annotations/class/main_test.go +++ b/internal/ingress/annotations/class/main_test.go @@ -44,7 +44,6 @@ func TestIsValidClass(t *testing.T) { {"nginx", "nginx", "nginx", true}, {"custom", "custom", "nginx", true}, {"", "killer", "nginx", false}, - {"", "", "nginx", true}, {"custom", "nginx", "nginx", false}, } diff --git a/internal/ingress/controller/listers.go b/internal/ingress/controller/listers.go index 568158c98..f3edc2f4b 100644 --- a/internal/ingress/controller/listers.go +++ b/internal/ingress/controller/listers.go @@ -31,7 +31,6 @@ import ( "k8s.io/ingress-nginx/internal/ingress" "k8s.io/ingress-nginx/internal/ingress/annotations/class" - "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ) type cacheController struct { @@ -66,7 +65,7 @@ func (n *NGINXController) createListers(stopCh chan struct{}) (*ingress.StoreLis AddFunc: func(obj interface{}) { addIng := obj.(*extensions.Ingress) if !class.IsValid(addIng) { - a, _ := parser.GetStringAnnotation(class.IngressKey, addIng) + a := addIng.GetAnnotations()[class.IngressKey] glog.Infof("ignoring add for ingress %v based on annotation %v with value %v", addIng.Name, class.IngressKey, a) return } @@ -103,11 +102,13 @@ func (n *NGINXController) createListers(stopCh chan struct{}) (*ingress.StoreLis curIng := cur.(*extensions.Ingress) validOld := class.IsValid(oldIng) validCur := class.IsValid(curIng) + + c := curIng.GetAnnotations()[class.IngressKey] if !validOld && validCur { - glog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey) + glog.Infof("creating ingress %v/%v based on annotation %v with value '%v'", curIng.Namespace, curIng.Name, class.IngressKey, c) n.recorder.Eventf(curIng, apiv1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name)) } else if validOld && !validCur { - glog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey) + glog.Infof("removing ingress %v/%v based on annotation %v with value '%v'", curIng.Namespace, curIng.Name, class.IngressKey, c) n.recorder.Eventf(curIng, apiv1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name)) } else if validCur && !reflect.DeepEqual(old, cur) { n.recorder.Eventf(curIng, apiv1.EventTypeNormal, "UPDATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name)) diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index ab0533a40..1798c733c 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -47,7 +47,6 @@ import ( "k8s.io/ingress-nginx/internal/ingress" "k8s.io/ingress-nginx/internal/ingress/annotations" "k8s.io/ingress-nginx/internal/ingress/annotations/class" - "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config" "k8s.io/ingress-nginx/internal/ingress/controller/process" ngx_template "k8s.io/ingress-nginx/internal/ingress/controller/template" @@ -258,7 +257,7 @@ func (n *NGINXController) Start() { ing := obj.(*extensions.Ingress) if !class.IsValid(ing) { - a, _ := parser.GetStringAnnotation(class.IngressKey, ing) + a := ing.GetAnnotations()[class.IngressKey] glog.Infof("ignoring add for ingress %v based on annotation %v with value %v", ing.Name, class.IngressKey, a) continue }