Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore ingress #9956

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/ingress/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ type Configuration struct {
DeepInspector bool

DynamicConfigurationRetries int

EnableAnnotationsPrefixCheck bool

DisableSyncEvents bool

Expand Down Expand Up @@ -309,8 +311,8 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
}

for key, value := range ing.ObjectMeta.GetAnnotations() {

if parser.AnnotationsPrefix != parser.DefaultAnnotationsPrefix {
klog.Warningf("EnableAnnotationsPrefixCheck set to false, Ignoring annotation check.")
if n.cfg.EnableAnnotationsPrefixCheck && parser.AnnotationsPrefix != parser.DefaultAnnotationsPrefix {
if strings.HasPrefix(key, fmt.Sprintf("%s/", parser.DefaultAnnotationsPrefix)) {
return fmt.Errorf("This deployment has a custom annotation prefix defined. Use '%s' instead of '%s'", parser.AnnotationsPrefix, parser.DefaultAnnotationsPrefix)
}
Expand Down
17 changes: 10 additions & 7 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"flag"
"fmt"
"net"
"os"
"time"

"github.com/prometheus/client_golang/prometheus"
Expand All @@ -35,6 +34,7 @@ import (
"k8s.io/ingress-nginx/internal/ingress/status"
ing_net "k8s.io/ingress-nginx/internal/net"
"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/pkg/apis/ingress"
klog "k8s.io/klog/v2"
)

Expand Down Expand Up @@ -219,6 +219,8 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
disableSyncEvents = flags.Bool("disable-sync-events", false, "Disables the creation of 'Sync' event resources")

enableTopologyAwareRouting = flags.Bool("enable-topology-aware-routing", false, "Enable topology aware hints feature, needs service object annotation service.kubernetes.io/topology-aware-hints sets to auto.")

enableAnnotationsPrefixCheck = flags.Bool("enable-annotations-prefix-check", true, "Enables check for value of legacy ingressclass annotation")
)

flags.StringVar(&nginx.MaxmindMirror, "maxmind-mirror", "", `Maxmind mirror url (example: http://geoip.local/databases.`)
Expand Down Expand Up @@ -366,12 +368,13 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
WatchWithoutClass: *watchWithoutClass,
IngressClassByName: *ingressClassByName,
},
DisableCatchAll: *disableCatchAll,
ValidationWebhook: *validationWebhook,
ValidationWebhookCertPath: *validationWebhookCert,
ValidationWebhookKeyPath: *validationWebhookKey,
InternalLoggerAddress: *internalLoggerAddress,
DisableSyncEvents: *disableSyncEvents,
DisableCatchAll: *disableCatchAll,
ValidationWebhook: *validationWebhook,
ValidationWebhookCertPath: *validationWebhookCert,
ValidationWebhookKeyPath: *validationWebhookKey,
InternalLoggerAddress: *internalLoggerAddress,
DisableSyncEvents: *disableSyncEvents,
EnableAnnotationsPrefixCheck: *enableAnnotationsPrefixCheck,
}

if *apiserverHost != "" {
Expand Down