Fix IngressClass logic for newer releases (#7341)
* Fix IngressClass logic for newer releases Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com> * Change e2e tests for the new IngressClass presence * Fix chart and admission tests Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com> * Fix helm chart test Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com> * Fix reviews * Remove ingressclass code from admission
This commit is contained in:
parent
0d57e87819
commit
cef147a24d
68 changed files with 1450 additions and 637 deletions
|
|
@ -24,10 +24,10 @@ import (
|
|||
|
||||
"github.com/spf13/pflag"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/class"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||
ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller/ingressclass"
|
||||
"k8s.io/ingress-nginx/internal/ingress/status"
|
||||
ing_net "k8s.io/ingress-nginx/internal/net"
|
||||
"k8s.io/ingress-nginx/internal/nginx"
|
||||
|
|
@ -55,10 +55,18 @@ only when the flag --apiserver-host is specified.`)
|
|||
Takes the form "namespace/name". The controller configures NGINX to forward
|
||||
requests to the first port of this Service.`)
|
||||
|
||||
ingressClass = flags.String("ingress-class", "",
|
||||
`Name of the ingress class this controller satisfies.
|
||||
The class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.18.0 or higher or the annotation "kubernetes.io/ingress.class" (deprecated).
|
||||
If this parameter is not set, or set to the default value of "nginx", it will handle ingresses with either an empty or "nginx" class name.`)
|
||||
ingressClassAnnotation = flags.String("ingress-class", ingressclass.DefaultAnnotationValue,
|
||||
`[IN DEPRECATION] Name of the ingress class this controller satisfies.
|
||||
The class of an Ingress object is set using the annotation "kubernetes.io/ingress.class" (deprecated).
|
||||
The parameter --controller-class has precedence over this.`)
|
||||
|
||||
ingressClassController = flags.String("controller-class", ingressclass.DefaultControllerName,
|
||||
`Ingress Class Controller value this Ingress satisfies.
|
||||
The class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.19.0 or higher. The .spec.controller value of the IngressClass
|
||||
referenced in an Ingress Object should be the same value specified here to make this object be watched.`)
|
||||
|
||||
watchWithoutClass = flags.Bool("watch-ingress-without-class", false,
|
||||
`Define if Ingress Controller should also watch for Ingresses without an IngressClass or the annotation specified`)
|
||||
|
||||
configMap = flags.String("configmap", "",
|
||||
`Name of the ConfigMap containing custom global configurations for the controller.`)
|
||||
|
|
@ -207,18 +215,6 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
|
|||
status.UpdateInterval = *statusUpdateInterval
|
||||
}
|
||||
|
||||
if *ingressClass != "" {
|
||||
klog.InfoS("Watching for Ingress", "class", *ingressClass)
|
||||
|
||||
if *ingressClass != class.DefaultClass {
|
||||
klog.Warningf("Only Ingresses with class %q will be processed by this Ingress controller", *ingressClass)
|
||||
} else {
|
||||
klog.Warning("Ingresses with an empty class will also be processed by this Ingress controller")
|
||||
}
|
||||
|
||||
class.IngressClass = *ingressClass
|
||||
}
|
||||
|
||||
parser.AnnotationsPrefix = *annotationsPrefix
|
||||
|
||||
// check port collisions
|
||||
|
|
@ -297,6 +293,11 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
|
|||
HTTPS: *httpsPort,
|
||||
SSLProxy: *sslProxyPort,
|
||||
},
|
||||
IngressClassConfiguration: &ingressclass.IngressClassConfiguration{
|
||||
Controller: *ingressClassController,
|
||||
AnnotationValue: *ingressClassAnnotation,
|
||||
WatchWithoutClass: *watchWithoutClass,
|
||||
},
|
||||
DisableCatchAll: *disableCatchAll,
|
||||
ValidationWebhook: *validationWebhook,
|
||||
ValidationWebhookCertPath: *validationWebhookCert,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue