-
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
Proposal: Server-side kubectl get
#363
Conversation
6b6346e
to
694d671
Compare
kubectl get
@kubernetes/sig-api-machinery-proposals |
@kubernetes/sig-cli-proposals @jwforres |
694d671
to
31ecb4e
Compare
|
||
Clients that wish to print in an advanced manner may continue to fetch the normal resources. | ||
|
||
Third-party resources can more easily implement `get` in this fashion - instead of web dashboards and |
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'd like to see a more in-depth description how this will work for TPR or all objects, in general. The proposal is very good, but what worries me is the same concern I raised in the Alternate API representations PR, how the server will know what to return for the user. Obviously for k8s objects, we can hardcode it, but I'm hoping that's not the direction here? I'd prefer seeing some sort of openapi extensions allowing us to express these printing options in the schema. I hope that makes sense.
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.
@pwittrock has a proposal about extending get
and describe
for TPR in #308, there seems to be some overlap between these.
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.
yes, and I think what @pwittrock suggested is for this case.
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.
Expectation would be:
On the server side, we would implement TPR printing by looking at the swagger spec or the TPR definition. The client wouldn't have to have a JSONPath library, they'd just get fields. If we wanted to implement a webhook for that, we could, and it would be transparent to clients (shameless plug to distract brendan)
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.
This seems like a problem that can be fixed with localized improvements to TPR so I'm not too worried about it.
@kubernetes/sig-cli-proposals |
## Goals | ||
|
||
* Make it easy for a simple client to get a list of resources for a web UI or CLI output | ||
* Support all existing options, leave open the door for future extension and experimentation |
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.
Support all existing options
Things not mentioned: sorting, display kind along with the name (this could be client-side).
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.
Sorting can be done client based on the type (numeric). I'm not sure what to do about Kind - a client can figure that out pretty well, and how clients specify kind is special (jessica isn't going to use pods/foo, she's going to do a link to the pods web page).
I have a bunch of other client side things to list here, will do that shortly.
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.
Cool, no issues with Kind being done on the client.
About sorting, doing on the client works for now, but we need to have sorting in mind when (if ever) server-side paging gets implemented.
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 don't think we're ever going to implement sort with server-side paging. Etcd doesn't support it natively without us dramatically increasing complexity, so it's not going to happen ;)
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.
👍
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.
In general, I'd like generic (resource-independent) rendering to be done in the client. Resource-specific computation and filtering of data to present should be on the server. For both get and describe.
Where we have complex computations in kubectl today (e.g., printPodBase), we need to add API fields. This new mechanism should just be returning existing data in a different format.
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.
Resource independent rendering is fairly difficult to do across the three major clients (IDE, CLI, and web UI) correctly for things like custom columns. But I agree it is simpler to let that be a per client decision. The tradeoff was allowing the object transformation to return the object itself (wrapped), since we don't want clients to have to do two LISTs and then merge them.
... | ||
], | ||
"items": [ | ||
{"cells": ["pod1", "Failed - unable to start", ...]}, |
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.
Alternatively make it a hash and key it with the value of "name" in the header, otherwise you have to rely on the ordering. Not a big issue since it's arrays though.
{"cells": {"Name": "pod1", "Status": "Failed - unable to start", ...}},
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 want to explicitly force clients to follow the rules. Mapping by name encourages people to get clever.
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 agree w/ the proposal as written. Tables should be indexed by row/column index not by row/name IMO. Also it's more bandwidth efficient this way.
There is no @kubernetes/sig-api-machinery-proposals team. :-( |
} | ||
``` | ||
|
||
To allow label columns, and to enable integrators to build effective UIs, each row may contain object metadata: |
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 define metadata for each type? what metadata we should return for TPR resources?
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.
This would be standard object metadata, OR it could be a runtime.Object and you have to ask for the object metadata. Note that this object is in metav1 / metaalphav1, which is an API that evolves. So until we break object meta, you can use this, and then in the future you can just ask for metav2.
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 think the server should produce a standardized metadata--clients shouldn't have to do something special if the resource is a TPR/AA.
Current unsolved problem - custom columns. If we let people send us arbitrary JSONPath templates, that could be a DoS attack area or resource amplification. Since the custom column has to be per object, it's really not that much more expensive than other expensive operations (creating a pod causes way more network traffic and general cluster load). We could potentially rate limit custom column requests if we had to. |
@smarterclayton @fabianofranz Do we have anyone lined up to implement this in 1.7? |
cc @bryk, since I imagine similar issues for the UI |
"apiVersion": "meta.k8s.io/v1alpha1", | ||
"headers": [ | ||
... | ||
{"name": "Node Name", "type": "string", "description": "The node the pod is scheduled on, empty if the pod is not yet scheduled", "priority": 1}, |
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.
Get headers and column values shouldn't contain spaces:
We use dashes instead of spaces in headers.
We also capitalize headers, but could do that generically in the client.
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 can normalize that in the client. I'm thinking of web uis, which have other affordances for communicating the difference between header and content. That's an important part of this proposal, not over normalizing for a cli
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.
Unless people will be copy-pasting headers in ways I don't expect I agree w/ Clayton.
``` | ||
$ curl https://localhost:8443/api/v1/pods -H "Accept: application/json+vnd.kubernetes.as+meta.k8s.io+v1alpha1+TableList" | ||
{ | ||
"kind": "TableList", |
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 have this problem with Lists also, but we're going to need to be able to paginate these. #2349
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 think the only difference here is that subsequent pages could omit the headers.
|
||
## Future considerations | ||
|
||
* When we introduce server side paging, TableList would be paged similar to how PodList or other types are paged. |
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.
Right. Please cite issues.k8s.io/2349
Re: custom columns. I think the way to solve this is adding a new field So there is a simple path from:
|
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, most comments are minor
|
||
## Specification of server-side `get` | ||
|
||
The server would return a `TableList` object (working-name) that contains metadata for columns and one or more |
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.
A TableList would be a list of tables. This is just a single table (right?). Perhaps Table
or TabularList
?
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 wanted it to have List
so it obeys our "list like behavior". Tabular sounds like Tubular
, but maybe this could just be Table
(and you always get a Table back). Will try with Table
.
... | ||
], | ||
"items": [ | ||
{"cells": ["pod1", "Failed - unable to start", ...]}, |
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 agree w/ the proposal as written. Tables should be indexed by row/column index not by row/name IMO. Also it's more bandwidth efficient this way.
{ | ||
"kind": "TableList", | ||
"apiVersion": "meta.k8s.io/v1alpha1", | ||
// headers are not returned here |
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.
Have you considered making this a separate kind?
Also, if someone uses this format and wojtekt's bulk watch, it's going to be impossible for clients to figure out what headers an object should have. I'm a little worried about not leaving a breadcrumb here to help them.
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.
Fair. Although in bulk watch you'll have the index on the wrapping event, so it's
Event
index: 0
Object:
Table ...
"apiVersion": "meta.k8s.io/v1alpha1", | ||
"headers": [ | ||
... | ||
{"name": "Node Name", "type": "string", "description": "The node the pod is scheduled on, empty if the pod is not yet scheduled", "priority": 1}, |
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.
Unless people will be copy-pasting headers in ways I don't expect I agree w/ Clayton.
} | ||
``` | ||
|
||
To allow label columns, and to enable integrators to build effective UIs, each row may contain object metadata: |
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 think the server should produce a standardized metadata--clients shouldn't have to do something special if the resource is a TPR/AA.
|
||
## Specification of server-side `describe` | ||
|
||
TBD |
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 would like to see here a statement that the server will be sending links to the client rather than performing the fan out itself, so we know the general shape of 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.
Ok
``` | ||
$ curl https://localhost:8443/api/v1/pods -H "Accept: application/json+vnd.kubernetes.as+meta.k8s.io+v1alpha1+TableList" | ||
{ | ||
"kind": "TableList", |
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 think the only difference here is that subsequent pages could omit the headers.
## Future considerations | ||
|
||
* When we introduce server side paging, TableList would be paged similar to how PodList or other types are paged. | ||
* More advanced output could in the future be provided by an external call-out or an aggregation API (which simply) |
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.
(cliffhanger)
header to indicate they want the simpler version, and if they receive a TableList perform the new path, otherwise | ||
fall back to client side functions. | ||
|
||
Server side code would reuse the existing display functions but replace TabWriter with either a structured writer |
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.
this is a little light on detail but that can wait for the PR ;)
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.
PR is already up!
@@ -0,0 +1,170 @@ | |||
# Expose `get` and `describe` output from the server |
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.
This title is a little ambitious given that this doesn't really cover describe :)
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 know. I'll refine.
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.
Moved to a future consideration and descoped the design.
Discuss how to move `kubectl get` to the server.
31ecb4e
to
550ae37
Compare
Proposal has been updated with all extant feedback and clarified the specific features of kubectl get and how they can / should be implemented |
This patch adds support for the "server-side GET operation" introduced by pull/40848 and proposed by kubernetes/community#363.
This patch adds support for the "server-side GET operation" introduced by pull/40848 and proposed by kubernetes/community#363.
Proposal: Server-side `kubectl get`
Automatic merge from submit-queue Proposal for adding PVC info to VolumeStats Flushes out details for part 1 of the changes described in [kubernetes#855](kubernetes#855) Feature: [kubernetes#363](kubernetes/enhancements#363)
Automatic merge from submit-queue (batch tested with PRs 44520, 45253, 45838, 44685, 45901) API for server side tabular output These are the APIs necessary to implement propsoal kubernetes/community#363 They consist of a new meta group (v1alpha1) that indicates these are alpha apis for the server as a whole, a new kind `TableList` which is a simple row + header arranged table capable of returning both object and columnar data, a `TableListOptions` for altering the behavior of the return, and `PartialObjectMetadata` which is an "interface" style API object which allows a client to ask any object for their metadata (without having to know how to parse the object or perform gymnastics). Extracted from #40848 A few minor tweaks still required. Kubernetes-commit: 6f4e0b66a7bfe1f0982722bced4f4b02807ac773
Automatic merge from submit-queue (batch tested with PRs 46432, 46701, 46326, 40848, 46396) Add a server side Get operation Implement proposal kubernetes/community#363 ```release-note The Kubernetes API supports retrieving tabular output for API resources via a new mime-type `application/json;as=Table;v=v1alpha1;g=meta.k8s.io`. The returned object (if the server supports it) will be of type `meta.k8s.io/v1alpha1` with `Table`, and contain column and row information related to the resource. Each row will contain information about the resource - by default it will be the object metadata, but callers can add the `?includeObject=Object` query parameter and receive the full object. In the future kubectl will use this to retrieve the results of `kubectl get`. ``` Kubernetes-commit: 97a5d378410f62437ea03c3db980a9a0af8a65ca
This proposal discusses how the
kubectl get
operation can be moved to the server to allow multiple clients to more easily show simple lists of objects.Part of kubernetes/kubernetes#12143 and general work under api-machinery.
Depends on:
Related to:
Prototype:
Some WIP items left, including a sketch of describe to contrast the two approaches.