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

Generic kubernetes api client #738

Conversation

yue9944882
Copy link
Member

@yue9944882 yue9944882 commented Oct 17, 2019

@brendandburns

NOTE: i will sanitize the pull l8r (the license, formatting, etc..)..

it's neat and simple. w/ the help of this generic client, what we only need is the generated model. i just drafted initial version of code and test, it already covers all the api paths on the kubernetes apiserver.

the general idea is to make use of CustomObjectApi as best as we can, this will help us access custom resources in kubernetes in an easier way. appreciated if you feel like shed some light on it

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 17, 2019
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 17, 2019
@yue9944882
Copy link
Member Author

note that #86 is solved in this pull, as is shown in the test..

@yue9944882 yue9944882 force-pushed the feat/generic-kubernetes-api-interface branch 3 times, most recently from 2704e24 to ca376b4 Compare October 18, 2019 07:36
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 18, 2019
@yue9944882
Copy link
Member Author

/hold

until #742 in

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 18, 2019
@brendandburns
Copy link
Contributor

@yue9944882 is this ready for review?

@yue9944882
Copy link
Member Author

@brendandburns let's freeze the pull until the migration to openapi-generator, the work isn't necessary to get into the next release i think.

@yue9944882 yue9944882 force-pushed the feat/generic-kubernetes-api-interface branch from ca376b4 to bba887e Compare December 27, 2019 08:07
@yue9944882 yue9944882 changed the title WIP: Generic kubernetes api client Generic kubernetes api client Dec 27, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 27, 2019
@yue9944882 yue9944882 force-pushed the feat/generic-kubernetes-api-interface branch 3 times, most recently from 0cb7bf9 to 76bfcef Compare December 27, 2019 10:27
@yue9944882
Copy link
Member Author

/hold cancel

@brendandburns let's move on reviewing this pull. @runzexia feel free to drop your comments too

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 27, 2019
@yue9944882 yue9944882 force-pushed the feat/generic-kubernetes-api-interface branch 2 times, most recently from 91fac76 to 07f32ff Compare December 31, 2019 08:59
@yue9944882
Copy link
Member Author

@brendandburns bumping for review


private Class<ApiType> apiTypeClass;
private Class<ApiListType> apiListTypeClass;
private String apiGroup;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to use the native Kubernetes object here for this? It has these fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

are you refering to V1APIGroup? the so-called field "apiGroup" here should be the name of the serving resource api group e.g. apps, networking.k8s.io, apiextensions.k8s.io, etc. while the V1APIGroup is used for representing all the fundamental information about the an api group . we need only a tiny bit of that, which is V1APIGroup#name. simply a string value would be sufficient, wdyt?

CustomObjectsApi customObjectsApi) {
if ("".equals(apiGroup)) {
throw new IllegalArgumentException(
"core group (\"\") not supported, use CoreV1Api otherwise");
Copy link
Contributor

Choose a reason for hiding this comment

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

should this say use "v1" instead

Copy link
Member Author

@yue9944882 yue9944882 Jan 10, 2020

Choose a reason for hiding this comment

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

updated to core group (v1) api not supported, use CoreV1Api instead, does that sound better?


import io.kubernetes.client.openapi.models.V1DeleteOptions;

public class DeleteOptions extends V1DeleteOptions {}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the purpose of this class?

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 added a class named ListOptions in this package and it's probably good to gather those option class into the same package. the DeleteOptions here is just a link to the generated delete option class. wdyt?

@@ -0,0 +1,71 @@
package io.kubernetes.client.extended.generic.options;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we use the generated class?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is a new class named ListOption introduced by this pull. the point of defining option classes here is to provide the developers a better programming interface, which looks making more logical sense comparing to those generated long-list parameters calls. in golang, we have similar option structs defined over the actual API parameters, developer works on that logical options and the SDK translates them to api interface options.. does that make sense to you?

Copy link
Contributor

@brendandburns brendandburns left a comment

Choose a reason for hiding this comment

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

Some comments. Thanks for this PR!

@yue9944882 yue9944882 force-pushed the feat/generic-kubernetes-api-interface branch from 07f32ff to ea084c4 Compare January 10, 2020 11:24
@brendandburns
Copy link
Contributor

@yue9944882 fwiw, I'm waiting on responses to the other comments before re-reviewing.

Let me know when it's ready for another pass.

Thanks!

@yue9944882
Copy link
Member Author

@brendandburns am i missing anything? i seem to replied the comments on the page. please let me know, thx!

@brendandburns
Copy link
Contributor

Was wondering about this comment:

#738 (comment)

@brendandburns
Copy link
Contributor

I guess it's fine, the plurals and everything else are represented in that object too, afaik.

But this seems like a fine place to start.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 22, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, yue9944882

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [brendandburns,yue9944882]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit a861a80 into kubernetes-client:master Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants