-
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
Support namespaced ingress without accessing the IngressClass #11223
Conversation
…ect and using the annotation. suggestions: IngressController needn't cluster level permission to access the IngressClass for namespaced Ingress consumer drop annotation "kubernetes.io/ingress.class" from ingress Consumer set the ingressClassName by ingress.Spec.IngressClassName IngressController accept the incoming ingress object when a) IngressController has permission to IngressClass, keep the current implementation. b) IngressController dont' have permission to access the IngressClass but ingress.Spec.IngressClassName is equals to the ingress class name specified by CLI parameter "--ingress-class"
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @yong-jie-gong. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
✅ Deploy Preview for kubernetes-ingress-nginx canceled.
|
|
@longwuyuan thanks for quick response.
with statement above, if applications are deployed in different customer environment secenario 1, scenario 2.2, all of Ingress objects in applications have to be created with IngressClassName(ingreess.spec.IngressClassName) for some customers or annotations(ingress.metadata.annotaiton.<ingress-classs>) for some other customer. besides, from k8s 1.24, it continue to print warnings if any ingress contains annnotation "kubernetes.io/ingress.class". Regarding namespace scoped instance, before k8s 1.24, Ingress object is pure the Namespace objects and not assoicate with cluster level resource IngressClass by attribute Ingress.Spec.IngresssClassName. |
@yong-jie-gong I think you completely missed the key aspects I pointed out.
So I don't think its a improvement to change the code of the project itself permanently to namespace scoped controller install. If you are installing this project's ingress-controller and the cluster-admin is not aware that a external-ip address is provisioned to input traffic into the cluster from outside the cluster, then that is a breach of trust and should not be allowed to happen. And then I glanced at your code changes. I am not a developer but from what I understand, your changes do not help other users of this project and your changes are not even implemented with best practices. For example you did not care to even write a test or describe what will happen to |
|
I request that you edit the issue-description in Issue #11222 as per below idea
|
@longwuyuan As requested, I has updated more information in defect #11222 |
@strongjz @tao12345666333 @rikatz @longwuyuan someone can help review? |
/assign I will add this to my list and finish the review this week. Thank you |
@tao12345666333 coudl you get time to check this PR? |
I will take a look today. Thank you for your contributions. |
return !strings.Contains(cfg, "server_name noclassforyou") | ||
return !strings.Contains(cfg, "server_name "+invalidHost) |
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.
Why did you change this?
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.
Hello @yong-jie-gong! First of all thank you very much for all the effort you put in this PR! We as the project maintainers recently had a meeting where we discussed the future of our project. Since we are comparable low on resources, we agreed on going in the direction of streamlining our code base to make is easier to maintain. This also includes sticking to the Kubernetes API given to us rather than building exceptions of it. We therefore sadly cannot accept your contribution anymore as it is not in alignment with the Ingress API. You're noting that this annotation is getting deprecated in Kubernetes v1.28. Actually and according to the code this warning is already in their since Kubernetes v1.27 and maybe even longer in other places because the annotation is not the preferred way for even longer already. Still considering it on its own in our code is one thing and we should probably get rid of it. But mixing it with the proper We hope you understand that! |
Had more discussion in slack channel kubernetes#sig-network and #ingress-nginx-dev
|
/reopen |
@yong-jie-gong: Reopened this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yong-jie-gong The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Why option 2 is not valid?
|
if icConfig.IgnoreIngressClass { | ||
if icConfig.AnnotationValue == *ing.Spec.IngressClassName { | ||
return *ing.Spec.IngressClassName, nil | ||
} |
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.
How to set
IgnoreIngressClass
to true or false ? Is there a helm chart related values-file key-value pair ?
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. 😅
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
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.
ingressClassName is the name of an IngressClass cluster resource. Ingress controller implementations use this field to know whether they should be serving this Ingress resource, by a transitive connection (controller -> IngressClass -> Ingress resource). Although the
kubernetes.io/ingress.class
annotation (simple constant name) was never formally defined, it was widely supported by Ingress controllers to create a direct binding between Ingress controller and Ingress resources. Newly created Ingress resources should prefer using the field. However, even though the annotation is officially deprecated, for backwards compatibility reasons, ingress controllers should still honor that annotation if present.
empty .spec.ingressClassName works functionally, but potentially, if multiple ingress-controllers are enabled to watch ingress with empty .spec.ingressClassName, it is not expected, that is why openshift consider it security alert https://access.redhat.com/solutions/7017955 |
Please take this comment into account: #11223 (comment). Additionally and as the API docs already say: Even though the annotation is officially deprecated, for backwards compatibility reasons, ingress controllers should still honor that annotation if present. We do this and Kubernetes right now is just warning you about usage, even in latest releases. Also neither Kubernetes nor this project are responsible for what a third party is warning you about. As in: I don't see a reason to change the code just because RedHat warns you about stuff. As long as you know your use case and setup best, you should always be able to run it the way you want it to and not the way someone else, who might not know your setup, tells you to. With the current implementation you could easily define a dummy I totally understand your use case and I also get that Ingress API is not covering it. IMHO the solution for overcoming API design flaws should never be breaking API compliance of an API implementation but rather pushing to fixing the API in newer versions. The issue you're addressing here is pretty clear: In the past there has been and still nowadays there is the Ingress resources are namespaced and as long as your controller is only watching Ingress resources of a specific namespace, one could easily run the controller in a quite isolated mode without access to any cluster-scoped resources. Now Since migrating from the annotation to We are aware of this design flaw and we also don't like it. But still this is no reason to break Ingress NGINX' compliance with the Ingress API. From here, we have several possibilities to proceed: At the moment some really encouraged folks are pushing forward Gateway API. Now is the perfect time to make sure it is not running into the same design flaws. So one could contribute to Gateway API and make sure it covers use cases like yours in the future. If this does not resonate with you, you could still approach SIG Network and talk about changes in the Ingress API. Anyway: Merging this PR is none of the possibilities and I therefore will close it again. |
…ect and using the annotation.
so it is better support namespaced ingressClass without accessing the IngresClass object and using the annotation.
suggestions:
What this PR does / why we need it:
with latest ingress/ingressClass design, there is no way to run application without requesting read permission on cluster level resource "IngressClass"
This is how issue happens
==As k8s administrator==
===As application administrator===
in demoapp1, there is some ingresses as below
in demoapp1, there is one ingress-controller deployed which watch all of ingress whose ingressClassName is "nginx". this ingress-controller should start and run without any error
as shown above, there is no cluster role binding for "application administrator" to install "demoapp1", it means any attempt to access k8s cluster resource will be denied
unfortunately, k8s reference doesn't provide clear guidance on how to valid the .spec.ingressClassName, so most of ingress-controller implementation will try to read the IngressClass object from .spec.ingressClassName.
obvisously, it will fail
in big shared k8s cluster, k8s administrator don't want to shared cluster level resource permission to applications running the namespace. so typically, they just provide least privileged kubeconfig for application installation
#11222 #11222
Types of changes
Which issue/s this PR fixes
ingress-controller/ingress can works without read permission on cluster reosurce "IngressClass"
fix #11222
How Has This Been Tested?
Checklist: