Skip to content
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

Client package proposal #15730

Merged
merged 1 commit into from
Dec 9, 2015
Merged

Conversation

lavalamp
Copy link
Member

I'm accumulating everything I've learned from talking with people about the client into a single proposal to make sure everyone is on the same page.

@smarterclayton @krousey @caesarxuchao

@lavalamp lavalamp added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Oct 15, 2015
@k8s-bot
Copy link

k8s-bot commented Oct 15, 2015

GCE e2e build/test failed for commit 50ca09edc2bb31dcb9bbda0ff7bb924fab7e0b29.

@k8s-github-robot
Copy link

Labelling this PR as size/L

@k8s-github-robot k8s-github-robot added kind/design Categorizes issue or PR as related to design. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 15, 2015
Extensions() ext_v1beta1.Client
Net() net_v1beta1.Client

GroupVersion(group, version string) generic.Client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I see it in next paragraph.

@lavalamp lavalamp added this to the v1.2 milestone Oct 16, 2015
@wojtek-t
Copy link
Member

/sub

somewhere. It consumes a Config object with options appropriate for this.
(That's most of the current client.Config structure.)

Third parties (e.g., open shift) may have their own implementation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenShift

abstain from commenting the same through doc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured someone would correct me, I just didn't know what to--I will fix. ;)

Copy link
Contributor

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 want Openshift or other clients to have their own implementation. I believe transport is generic to "Kube-like" APIs - standard auth, security, behavior, and other patterns. A kube like API should be able to use the Kube like transport

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK-- I think I interpreted your comments in the previous discussion at the wrong level of meta. See if you agree now.

@derekwaynecarr
Copy link
Member

@lavalamp - I am interested in also defining a client pattern that lets me take an APIResource and perform generic ObjectMeta oriented LIST, DELETE(item) request/response.

use case is for namespace controller to allow generic deletion pattern:

  1. find all namespaced resources via discovery client
  2. for each namespaced resource, do a LIST(resource), DELETE(item) flow

so this client would know how to build URL paths given arbitrary APIResource definition.

thoughts?

@lavalamp
Copy link
Member Author

@derekwaynecarr I absolutely think we should support that, and I think that falls well within the scope of what I've imaginatively called the generic client.

We can also extend the things like runtime.Unknown/Unstructured to provide metadata manipulation abilities for arbitrary (api-conforming) objects.

for executing discovery commands. The group and version may be overridable with
a function call.

RESTClients may have semantic information built in. For example, if the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be accomplished at the transport layer? Currently you can provide your own transport or even provide something that wraps a transport. I imagine this RESTClient could just consume a transport that does this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible, but I'm imagining a different RESTClient per group/version, with all of them sharing a common Transport. We do want to cache & reuse transports if possible, on account of http connection reuse.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be relatively simple to wrap a shared transport for different clients. HTTPWrappersForConfig does this already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Clayton points out, we should keep as much semantic info in the Codec as possible.

@lavalamp
Copy link
Member Author

Thanks for the comments everyone-- I will update accordingly, perhaps on Monday.

@smarterclayton
Copy link
Contributor

I'll try and take a look before Monday.

On Oct 16, 2015, at 5:41 PM, Daniel Smith notifications@github.com wrote:

Thanks for the comments everyone-- I will update accordingly, perhaps on
Monday.


Reply to this email directly or view it on GitHub
#15730 (comment)
.

appropriate query parameter when you call the "LabelSelector()" method.

3rd parties such as open shift may provide their own implementation, but it
should conform to the same interface as the standard RESTClient.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, any go code implementing a Kube like API should be able to reuse the standard impl. No "hacks" specific to a certain API group should be in this layer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

below).
* `GroupName()` returns the generated client that this section is about.
* `NamespaceSpecifier()` may take a namespace parameter or nothing.
* `Action` is one of Create/Get/Update/Delete/Watch, or appropriate actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to settle on the pattern for sub resources. You don't have to do it here, but I'd like the current state called out as "insufficiently defined"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@caesarxuchao
Copy link
Member

Will kubectl use a pre-built clientset, or shall it build its clientset at runtime according to the versions specified in kubeconfig?


# Client: layering and package structure

## Desired layers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOC and/or TL;DR of the proposed layers / modules.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added TOC

@k8s-bot
Copy link

k8s-bot commented Nov 19, 2015

GCE e2e test build/test passed for commit 6f8fcbfacc9a5015ba92e42feeb8eab5f20bf336.

@smarterclayton
Copy link
Contributor

One thought I had today - we really should manage and version the conversions and API objects outside of the core Kube package somehow.

Having go code that can take a v1beta3 object and convert it to v3 (even if it's lossy to reverse) is generally useful. Being able to keep old conversions over a long lifetime seems useful. It would also make it easy to control lifecycle of API external versions.

@lavalamp
Copy link
Member Author

lavalamp commented Dec 2, 2015

OK, I pushed a new revision.

@caesarxuchao

Will kubectl use a pre-built clientset, or shall it build its clientset at runtime according to the versions specified in kubeconfig?

kubectl should use the dynamic client as much as possible, and for things that it has special knowledge of, it should use a pre-built clientset.

@smarterclayton

we really should manage and version the conversions and API objects outside of the core Kube package somehow.

Agree, but outside the scope of this doc...

One concrete proposal that I think fits into a lot of our general problems:

We need to build, demonstrate, and test against an "out-of-tree" api group for client, scaler, and general logic like autoscaler
When we make changes to the client library, we should ensure that keeps working (without being able to refactor that code)
We need to use that to prove, test, and verify the discovery, generic references across types, and api groups problems.

I added lines for the first two in various places.

@lavalamp
Copy link
Member Author

lavalamp commented Dec 2, 2015

@smarterclayton if you're happy with these changes I'll squash and we can get this in :)

@caesarxuchao
Copy link
Member

kubectl should use the dynamic client as much as possible, and for things that it has special knowledge of, it should use a pre-built clientset.

My point is, if kubectl uses the pre-built clientset, then the version is decided at compile time, the APIVersion field in kubeconfig will be meaningless. Perhaps we should just remove that field from kubeconfig.

@smarterclayton
Copy link
Contributor

I'm fine with changes, LGTM

@smarterclayton
Copy link
Contributor

There can be multiple built in clientsets

On Dec 2, 2015, at 6:10 PM, Chao Xu notifications@github.com wrote:

kubectl should use the dynamic client as much as possible, and for things
that it has special knowledge of, it should use a pre-built clientset.

My point is, if kubectl uses the pre-built clientset, then the version is
decided at compile time, the APIVersion field in kubeconfig will be
meaningless. Perhaps we should just remove that field from kubeconfig.


Reply to this email directly or view it on GitHub
#15730 (comment)
.

@caesarxuchao
Copy link
Member

There can be multiple built in clientsets

Sure, we can switch clientset based on the specified "group/version", but I imagine the code won't be elegant, because you need to translate "group/version" to the the release version of clientset somehow.

@k8s-bot
Copy link

k8s-bot commented Dec 2, 2015

GCE e2e build/test failed for commit a873007f4115e2343aa3ff101f9a8528269388ad.

@smarterclayton
Copy link
Contributor

Why is that hard? We already have to have scheme registries in clients for
conversions.

On Dec 2, 2015, at 6:47 PM, Chao Xu notifications@github.com wrote:

There can be multiple built in clientsets

Sure, we can switch clientset based on the specified "group/version", but I
imagine the code won't be elegant, because you need to translate
"group/version" to the the release version of clientset somehow.


Reply to this email directly or view it on GitHub
#15730 (comment)
.

@caesarxuchao
Copy link
Member

Sorry I don't follow. Let's look at a concrete example. (https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/portforward.go#L104-L109)

    client, err := f.Client()
    if err != nil {
        return err
    }
    pod, err := client.Pods(namespace).Get(podName)

In this proposal, the client should now be a pkg/client/clientset/release-X.Y#client, and the returned pod will be a vZ.pod. How are we going to rewrite this piece of code? I think we can't even switch among different clientsets, because the the clients in different sets are of different types.

@lavalamp
Copy link
Member Author

lavalamp commented Dec 9, 2015

Squashed. Let's merge and we can make changes later if needed.

@k8s-bot
Copy link

k8s-bot commented Dec 9, 2015

GCE e2e test build/test passed for commit dc5e1ea.

@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 9, 2015
@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Dec 9, 2015
@k8s-github-robot k8s-github-robot merged commit 598e3b0 into kubernetes:master Dec 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/design Categorizes issue or PR as related to design. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.