-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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 to kubectl describe ingress output #107921
Add Ingress Class to kubectl describe ingress output #107921
Conversation
Hi @mpuckett159. 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. |
For the changelog, I'd write
|
Yup that's more accurate, thank you. |
/ok-to-test |
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.
Code looks good.
Can you squash your commits?
(ref: https://www.kubernetes.dev/docs/guide/github-workflow/#squash-commits)
440801a
to
8b54191
Compare
Question: Is printing an empty string preferable to printing something like I don't think I have a preference, but wonder if there is already a precedent for this somewhere else in describe. |
From my reading of the ingress docs just before the
An ingress does not technically require a class, which, imo, should result in printing a blank or I can add that if it sounds good. |
Nor do I unfortunately. The more I read about this the more it looks like I need to write a function to check a few things before populating a value. The IngressSpec API docs show that there is also a deprecated annotation to take into account that takes precedence over the actual Seems similar to kubernetes/kubectl#1133, actually. |
34226dd
to
742de7f
Compare
I think what I've landed on after some reading and testing is the following:
Something to note, currently when doing a ❯ kc get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress <none> hello-world.info localhost 80 27m I'm not sure if it's desirable to show the inferred class name for get or just stick with what is explicitly set in the Ingress object itself in this situation, however. If we're only fetching what is explicitly set in the config then It also probably makes more sense, since I'm doing all these checks now, to say |
If I’m a little hesitant to try to reimplement the ingress class default/precedence rules inside kubectl. It seems like this could be tricky, especially since it sounds like some ingress providers can work without a default class name. I’m open to it, but just want to keep things simple if possible. I understand if there is value in doing this though. I’d like to hear from someone else who maybe has more experience than I do with ingress. @rikatz any thoughts on this? @eddiezane thoughts? |
tl;dr because I wrote too much: I think having ingress class reflecting the ingressClassName is fine :) The part where I write too much: IngressClass is a tricky implementation. Right now, we have the "deprecated" annotation, and the new ingressClassName spec field. Users still tends to use (a lot!) the annotation and even in ingress nginx we are thinking on rolling back this "deprecation". It was a really noisy change. From my perspective, as the field is the "official" way of saying who "owns" that ingress, it's fine to print that field content and only it. Now going to the "how useful this is": some controllers does not implements class, while others implement on different ways. As far as I remember a class can only be used if it exists and was created by the clusteradmin, so users cannot add random things, and it's good on a description to know "who owns that ingress". I have a feeling right now that this solves half the problem: we have a description, but we don't have the "feedback" of if a controller from that class properly implemented that ingress but this is another discussion on the lack of status and conditions on ingress objects and I'm done on my KEP quota this year :) |
Just complementing now that I read the whole thread: I wouldn't go with "how ingressA or B does". Stick with the API spec :) Annotation is deprecated. An ingressClassName can be empty, so either it's "none" or it's the value on the field. This is my opinion. Anything other than that is too specific and can lead to situations like "controller A does this way and you don't cover", etc. The API is our contract, and we should follow it. |
For easier reference re API for Ingress:
Which is how I arrived at:
|
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.
Left some reviews.
@@ -2731,6 +2733,70 @@ func (i *IngressDescriber) describeIngressV1beta1(ing *networkingv1beta1.Ingress | |||
}) | |||
} | |||
|
|||
func describeIngressClassNameV1beta1(w PrefixWriter, ing *networkingv1beta1.Ingress, i *IngressDescriber) { |
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.
Hum, v1beta1 is in path to be removed from the API, so I don't think we should take care of this :)
Based on kubectl/apiserver skew contract, you should support -3 versions, which is v1.21 that already supports ingress v1 :)
} | ||
// kubernetes.io/ingress.class annotation is deprecated but takes precedence over everything, skip querying | ||
// apiserver to save resources if we find the deprecated annotation as it takes precedence anyway | ||
ingAnnotations := ing.GetAnnotations() |
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.
I wouldn't use this. Annotations are deprecated, this is stated on the API. We should stick with the API description on 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.
According to the API:
For backwards compatibility, when that annotation is set, it must be given precedence over this field.
@rikatz Are you saying it is fine to simply display the value of ingressClassName directly, without doing any additional lookup of the default if it is nil? I think that is where I am headed: just show the value, if it is set, otherwise if nil then print do you think this is good enough? |
Yeap, I'm a +1 to keep it simple right now. It's still confusing for users this annotations vs ingressClass thing, so let's state that ingressClass is the ingressClassName field, and IMHO move on :) |
I just wanted to double check, because I feel like I'm not on the same page as everyone else, but from my understanding of the API docs, it sounds to me like the annotation takes precedence, so if we really wanted to reflect reality back to the user it seems like we should be showing that annotation back if it exists as that's what the ultimate applied class will be. |
After sleeping on it I think what everyone is saying is that k8s.io/api/networking/v1(beta1) is where we should really implement the logic that I've written and have a function made available so that anyone can figure out the actual applied IngressClassName. That sounds correct to me, and if that's the consensus, I can scale back this commit back to where it's just reading the IngressClassName property and make an issue/PR for adding a function to "calculate" the actual applied Ingress Class based on the outlined logic from the docs, and whenever that's pulled in we can update the describe code here to utilize that function properly. |
043c5c5
to
e7e2bfd
Compare
Alright all that makes sense to me now, thanks everyone for the input. I've basically reset to the original PR commits and updated the Ingress Class output to show |
/retest |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brianpursley, mpuckett159 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks @mpuckett159 👍 |
/kind feature
What this PR does / why we need it:
This PR adds the Ingress Class to the output of
kubectl describe ingress
Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#1160
Special notes for your reviewer:
Based on the Ingress.Spec.IngressClassName comments (linked below) it looks like this should just be blank if the name isn't specified, so I'm setting to an empty string then updating if the name is provided.
kubernetes/staging/src/k8s.io/api/networking/v1/types.go
Line 257 in 2b091f6
Does this PR introduce a user-facing change?