-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Support namespaced ingress without accessing the IngressClass #11223
Closed
yong-jie-gong
wants to merge
17
commits into
kubernetes:main
from
yong-jie-gong:fix_namepaced_ingress_issue
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
61343bb
Support namespaced ingressClass without accessing the IngresClass obj…
24c4ec9
fix indent issue
5ff4253
Fix indent issue
d14ca86
Rollback go.work.sum
43354dd
Rollback go.work.sum
f7556a3
Fix unitest issue
8ef4db3
fix unitest issue
cae5005
set ingressClassName and fix unitest issue
51c58c3
update unittest
c97e62a
skip IngressClassName validation when no permission on IngressClass
a436a32
fix indent issue
dadd1c0
indent-error-flow: if block ends with a return statement, so drop thi…
bd7f2e8
typo erro
a4a5367
fixed unitest error
2653b8e
fix unitest
7c2b047
fix unitest issue
9d3afe4
Merge branch 'main' into fix_namepaced_ingress_issue
yong-jie-gong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -645,14 +645,35 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { | |
Status(http.StatusOK) | ||
}) | ||
|
||
ginkgo.It("should watch Ingress with matched Ingress.Spec.IngressClassName and CLI parameter --ingress-class", func() { | ||
validHost := "validhostnameforingressclassname" | ||
testIngressClassName := "testclass" | ||
|
||
ing := framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, framework.EchoService, 80, nil) | ||
ing.Spec.IngressClassName = &testIngressClassName | ||
f.EnsureIngress(ing) | ||
|
||
f.WaitForNginxConfiguration(func(cfg string) bool { | ||
return strings.Contains(cfg, "server_name "+validHost) | ||
}) | ||
|
||
f.HTTPTestClient(). | ||
GET("/"). | ||
WithHeader("Host", validHost). | ||
Expect(). | ||
Status(http.StatusOK) | ||
}) | ||
|
||
ginkgo.It("should ignore Ingress with only IngressClassName", func() { | ||
invalidHost := "noclassforyou" | ||
unmatchedIngressClassName := "testclass-unmatched" | ||
|
||
ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, framework.EchoService, 80, nil) | ||
ing.Spec.IngressClassName = &unmatchedIngressClassName | ||
f.EnsureIngress(ing) | ||
|
||
f.WaitForNginxConfiguration(func(cfg string) bool { | ||
return !strings.Contains(cfg, "server_name noclassforyou") | ||
return !strings.Contains(cfg, "server_name "+invalidHost) | ||
Comment on lines
-655
to
+676
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}) | ||
|
||
f.HTTPTestClient(). | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you ignore IngressClassName for one thing but use it for another thing?
This is not right IMHO, you are changing the semantics of two options, one public API of Ingress and one config of ingress-nginx ... this is a -1 as it is a breaking change for two things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
==Before change, if IgnoreIngressClass is false and ing.Spec.IngressClassName is not empty, ingress-controller mandate the IngressClass validation. it mean fails directly if no read permission on IngressClass resource
==After change
if IgnoreIngressClass is false and ing.Spec.IngressClassName is not empty, stay as before. if IgnoreIngressClass is true && ( ing.Spec.IngressClassName == <ingress class defined by cli "--ingress-class" ), ignore the IngressClass resource matchness check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to set
IgnoreIngressClass
to true or false ? Is there a helm chart related values-file key-value pair ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can always pass it as
controller.extraArgs
. I never got why users would add new values to the chart for stuff that's just being passed directly in to the arguments. But that's not to be discussed here, just my 2 cents. 😅And that's what @aojea means:
.spec.ingressClassName
and what is should be used for is defined by a public API. We are not going to break this API.https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#ingressspec-v1-networking-k8s-io