-
Notifications
You must be signed in to change notification settings - Fork 270
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
Add --ingress-class-precedence to allow IngressClass taking precedence over annotation #857
Add --ingress-class-precedence to allow IngressClass taking precedence over annotation #857
Conversation
I haven't add reviewers so requesting a review from @jcmoraisjr :-) |
Thanks for the contribution and sorry about taking so long to comment. I'd suggest you two main changes: ingressClassPrecedence = flags.Bool("ingress-class-precedence", false,
`Defines if IngressClass resource should take precedence over
kubernetes.io/ingress.class annotation if both are defined and conflicting.`) This is a suggested change in the name and description with two benefits: better fits the purpose of the functionality and also avoids to change the whole struct, which leads to conflict when merging or cherry-picking. The other suggestion is to try to add the warning message if cfg is true - ie using the functionality will only change the precedence in the case of a conflict, but still warning when the conflict happens. Please let me know if you need anything, I'll answer faster this time =) |
@jcmoraisjr sounds reasonable. I updated the code. Please take a look to make sure I have not skipped some condition. :-) |
I ended up with this piece of code, it'll only add a new logic, compared with the original code, if the config is true. Please check if it makes sense to you: // c.cfg.IngressClassPrecedence as `true` gives precedence to IngressClass
// if both class and annotation are configured and they conflict
if hasAnn {
if hasClass && fromAnn != fromClass {
if c.cfg.IngressClassPrecedence {
c.logger.Warn("ingress %s/%s has conflicting ingress class configuration, "+
"using ingress class reference because of --ingress-class-precedence enabled (%t)",
ing.Namespace, ing.Name, fromClass)
return fromClass
}
c.logger.Warn("ingress %s/%s has conflicting ingress class configuration, using annotation reference (%t)",
ing.Namespace, ing.Name, fromAnn)
}
return fromAnn
} You can also add the starting version, this pr will be cherry-picked to v0.13:
Adjust the alignment in the And finally, try to squash all the resulting commits into a single one. Thanks! |
…dence over ingress annotation
@jcmoraisjr should be fine now |
Great, lgtm, thanks! Merging now. |
@jcmoraisjr are you planing to release some new minor version that would also contain this change? :-) |
Hi, sorry about the delay in the response. v0.13.5 was just released and has this feature merged. |
When defined as true,
--controller-class-precedence
with give a precedence to controller class over kubernetes.io/ingress.class annotation. This will be especially useful while migrating from one approach to another having zero downtime in mind. It can be removed once the support of ingress annotation is fully disabled.I am here referring to situation when both IngressClassName and ingress annotation are defined in Ingress which results in
W0923 07:50:41.725353 7 cache.go:715] ingress prometheus/prometheus has conflicting ingress class configuration, using annotation reference (false)
in haproxy ingress controller logs.