Resolved: Why is –verbs=list option required when I get all resources in the k8s namespace?

Question:

Why do I have to use --verb=list option when I list all resources in the k8s namespace?
I read this question and linked GitHub issue, and they worked for me. However, I cannot understand why --verb=list option is used.
Thanks to the help, I now know what this option does. When I add this option, the command shows only resources which support list verb. However, I could not figure out why it was necessary to show only the resources that support the list verb.
Please teach me this.

Answer:

The question you quoted was to list resources. To be able to list, the resource must support the listing. Based on official documentation:
kubectl api-resources --verbs=list,get       # All resources that support the "list" and "get" request verbs
In the case of documentation, we have 2 verbs (list, get), you had one (list). The idea is for the command to return only those api-resources which handle list verb.
In conclusion, the --verb=list flag was used to limit the results to only those that support the listing.

I could not figure out why it was necessary to show only the resources that support the list verb.


This solution is good if, for example, later you want to work on api-resources using only the list. If you would like to operate on a resource that does not support it, you will get an error similar to this:
kubectl list tokenreviews
error: unknown command "list" for "kubectl"

Did you mean this?
        get
        wait
To avoid this situation you can filter results before with the flag --verb=list.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

If you like this answer, you can give me a coffee by click here (view Ads)