-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
kubectl get
and kubectl describe
extensions
#308
kubectl get
and kubectl describe
extensions
#308
Conversation
…ns for non-compiled in types.
kubectl get
and kubectl describe
extensio…kubectl get
and kubectl describe
extensions
FYI: @duglin |
thanks @pwittrock! |
get and describe function based on resource builders (as distinct from create). If you allow people to claim a name under |
Question I would like to see answered: How does this behavior play with third-party resources and the naming scheme there? Which takes precedence? |
Currently, thirdpartyresources are not special. They are exposed via discovery and the |
@deads2k Well, that is partially true as you can have two third party resources that are both called "operator". In that case someone can still use |
True, but in practice claiming a section of the value-space via extension like this feels like cheating. We wouldn't let people do it in tree because of name stealing, it doesn't seem like we'd want to allow it from out of tree. |
Right, and the decision about which takes precedence is up to the cluster-admin of the server hosting the resources. Making the generic kubectl operations work consistently via discovery puts control of precedence for a particular server in the cluster-admin's hands. Two users running |
Allow the apiserver to define the type specific columns that will be | ||
printed using the open-api swagger.json spec already fetched by kubectl. | ||
This provides a limited describe to only print out fields on the object | ||
and related events. |
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 do you envision this interacting with kubernetes/kubernetes#33900 ?
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.
Good question. I guess I don't fully understand how that proposal is intended to interact with the swagger schema. I suspect that this proposal is a much lighter version of the sub-pieces of kubernetes/kubernetes#33900 dealing with getting metadata about objects.
Define the open-api extensions `x-kubernetes-kubectl-get-columns` and | ||
`x-kubernetes-kubectl-describe-columns`. These extensions have a | ||
string value containing the columns to be printed by kubectl. The | ||
string format is the same as the `--custom-columns` for `kubectl get`. |
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.
we don't have openapi schemas for third party resources... do we anticipate adding that in the future?
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.
Thanks for pointing that out. I just added some comments about this. The short answer is - Yes I would like to add support for TPR. My initial thought is that this can be done through an annotation on the TPR. If we implement this proposal by hooking into the RestMapper, supporting TPR should be relatively clean. If we hack this proposal in, then it would be less clean.
PTAL. I have added sections to the implementation part that should clarify things. TL;DR: @philips TPRs are not being targeted for the alpha version since they will never appear in the swagger.json, but their future integration is being considered as part of the implementation considerations. @deads2k I wasn't planning on overriding the resource builder, but instead either integrating with it by having it parse the extensions when present. |
would you envision that happening at the two spots we print objects we don't otherwise know about? and |
@liggitt Yes that is what I was thinking. Not certain of the best way to plumb the data there though. |
This seems to have some overlapping with #363. |
The intent would be that the implementation of this be done on the server side, which simplifies clients (they don't have to look at swagger at all). |
This provides a limited describe to only print out fields on the object | ||
and related events. | ||
|
||
**Note:** This solution will only work for types compiled into the apiserver |
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.
include federated apiservers?
cc @kubernetes/sig-cli-proposals @kubernetes/sig-api-machinery-proposals @kubernetes/sig-service-catalog-proposals |
@pwittrock @fabianofranz @smarterclayton Maybe this should be hashed out in a joint SIG CLI / API machinery meeting? Or choose one of the meetings? |
In general, I'd like OpenAPI to provide rich, complete, accurate info for clients, but for the most commonly needed functionality to be implemented in the apiserver and controllers (e.g., GC). kubernetes/kubernetes#12143 Example: Schema validation today is done in the client using OpenAPI, but I'd like to provide this optionally in the server: kubernetes/kubernetes#5889. Multi-platform orchestrators like ManageIQ, Ansible, Puppet, Google Deployment Manager, etc. may choose to use OpenAPI, but simpler K8s-specific clients should be able to request schema validation. We don't want to have to write that in 6+ languages (Go, Python, Java, Javascript, Ruby, PHP, ...). In this case, as I commented https://github.com/kubernetes/community/pull/363/files#r111605582, I envision resource-specific computation and filtering to happen in the server, and rendering to be done in the client. For TPR, I imagine accepting the same OpenAPI format that K8s returns for built-in resources, whether from the primary apiserver or aggregated ones. That would support schema validation, declarative value validation and defaulting (kubernetes/kubernetes#25460), get, describe, diff, merge, apply, edit, explain, external orchestrators, client-library generation, documentation generation, etc. We shouldn't invent yet another schema for enabling those things, other than our types.go-based annotations (currently a combination of tags and comments), until/unless that's replaced by another IDL. |
…d_describers Automatic merge from submit-queue (batch tested with PRs 44222, 44614, 44292, 44638) Smarter generic getters and describers Makes printers and describers smarter for generic resources. This traverses unstructured objects and prints their attributes for generic resources (TPR, federated API, etc) in `kubectl get` and `kubectl describe`. Makes use of the object's field names to come up with a best guess for describer labels and get headers, and field value types to understand how to better print it, indent, etc. A nice intermediate solution while we don't have [get and describe extensions](kubernetes/community#308). Examples: ``` $ kubectl get serviceclasses NAME KIND BINDABLE BROKER NAME OSB GUID user-provided-service ServiceClass.v1alpha1.servicecatalog.k8s.io false ups-broker 4f6e6cf6-ffdd-425f-a2c7-3c9258ad2468 ``` ``` $ kubectl describe serviceclasses/user-provided-service Name: user-provided-service Namespace: Labels: <none> Annotations: FOO=BAR openshift.io/deployment.phase=test OSB Metadata: <nil> Kind: ServiceClass Metadata: Self Link: /apis/servicecatalog.k8s.io/v1alpha1/serviceclassesuser-provided-service UID: 1509bd96-1b05-11e7-98bd-0242ac110006 Resource Version: 256 Creation Timestamp: 2017-04-06T20:10:29Z Broker Name: ups-broker Bindable: false Plan Updatable: false OSB GUID: 4f6e6cf6-ffdd-425f-a2c7-3c9258ad2468 API Version: servicecatalog.k8s.io/v1alpha1 Plans: Name: default OSB GUID: 86064792-7ea2-467b-af93-ac9694d96d52 OSB Free: true OSB Metadata: <nil> Events: <none> ``` **Release note**: ```release-note Improved output on 'kubectl get' and 'kubectl describe' for generic objects. ``` PTAL @pmorie @pwittrock @kubernetes/sig-cli-pr-reviews
Exact swagger tag names TBD |
add some docs PR links
`kubectl get` and `kubectl describe` extensions
…ns for non-compiled in types.
@fabianofranz The sig-service-catalog was going to fork kubectl and compile in custom types for get and describe to work. I really don't like this solution, and think we could support their needs in a simple way.
Would you be open to discussing this on Wednesday?
sig-service-catalog has agreed to donate the development resources to implement. @simonleung8