Question:Why do I have to use
--verb=listoption 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=listoption 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:
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.
kubectl api-resources --verbs=list,get # All resources that support the "list" and "get" request verbs
In conclusion, the
--verb=listflag 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:
To avoid this situation you can filter results before with the flag
kubectl list tokenreviews error: unknown command "list" for "kubectl" Did you mean this? get wait
If you have better answer, please add a comment about this, thank you!
If you like this answer, you can give me a coffee by click here (view Ads)