Skip to content

Adding support for GKE in KubeConfig #119

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

Closed
bchapuis opened this issue Nov 16, 2017 · 10 comments
Closed

Adding support for GKE in KubeConfig #119

bchapuis opened this issue Nov 16, 2017 · 10 comments

Comments

@bchapuis
Copy link

It is possible to connect to a remote kubernetes cluster hosted by google (GKE) with the following command, which automatically updates the .kube/config file:

gcloud container clusters get-credentials CLUSTER_NAME --zone ZONE_NAME --project PROJECT_NAME

It would be nice if this kind of configuration was supported by the java client out of the box.

@brendandburns
Copy link
Contributor

This would involve integrating the GKE library into this library... It feels kind of out-of scope for the client library to do this.

@lwander @mbohlool what do you think?

I suppose we could add a cloudprovider package or somesuch...

@bergman
Copy link

bergman commented Dec 19, 2017

I can see how this is out of scope for the client and should perhaps be handled by some plugin for each different type of auth or cloud provider. On the other hand, opening up to another type of authentication and configuration besides reading ~/.kube/config would be great. Basically being able to from my application connect to a different master without having to instantiate a KubeConfig object which is quite opaque to me.

@mbohlool
Copy link
Contributor

Some configurations in kubeconfig require the client to run a refresh command. GCP provider is one (and the only one I know) of them. I think it is resonable to support use case of refreshing token if it is already in kubeconfig file, but retrieving configuration from different client providers is out of the scope of client libraries and should be a separate library/command. to @bergman I think it is useful to generalize the configuration object (if it is not already) to be able to support other auth providers.

@brendandburns
Copy link
Contributor

@bergman just for completeness, there are a wide variety of ways to load configs other than ~/.kube/config.

The easiest is to set the export KUBECONFIG=/some/path/to/config environment variable to some other config file, and the code will automatically pick up from that .

But there are other programatic approaches also, for example:
https://github.com/kubernetes-client/java/blob/master/util/src/main/java/io/kubernetes/client/util/Config.java#L106

Hope that helps.
--brendan

@brendandburns
Copy link
Contributor

I'm going to close this, since it's out of scope for the library.

@bergman
Copy link

bergman commented Dec 20, 2017

@brendandburns all of those options require a file (could be virtual I guess and made programmatically within your code, but still) in the format of ~/.kube/config or KubeConfig. What I'm requesting is a way to instantiate a KubeConfig object from something other than a file such that I can programmatically switch to some other cluster/master etc based on e.g. runtime config of my application. Sure, I could shell out to whatever generates my ~/.kube/config and configure a new client from that but that's not a good experience for anyone.

Even if you do open up to some plugins for doing auth and configuration for different providers, they will need some API to do so and generating a virtual file to do that is not great.

Agree on closing this issue as it relates only to GKE. Please point me to where we can have the more general discussion on making it simpler to use with any provider.

@brendandburns
Copy link
Contributor

@bergman I think I must not understand, you can instantiate a KubeConfig object just like any other Java object:

KubeConfig kc = new KubeConfig(...);
...

See:
https://github.com/kubernetes-client/java/blob/master/util/src/main/java/io/kubernetes/client/util/KubeConfig.java#L91

Is this because there aren't setters for the KubeConfig object? Or is it because the objects within the config aren't strongly typed?

I can see an argument for both of those features.

If you want one (or both) please open separate issues like "make KubeConfig sub-objects strongly typed" or somesuch...

Thanks!

@brendandburns brendandburns reopened this Dec 20, 2017
@brendandburns
Copy link
Contributor

@bergman friendly ping for more info if you want...

thanks!

@bergman
Copy link

bergman commented Dec 28, 2017

@brendandburns thanks for getting back to me! I'm on holidays so sorry for the delayed response. You're right, it's possible to instantiate a KubeConfig but as you noted, it's not especially clear how with those untyped collections. I will take another stab at this when I get back to work next week.

Something that would allow me to do something like this is what I'm after:
https://github.com/spotify/styx/blob/c0654ac66a74692ffbc6974b824f3d763a6e6bc4/styx-scheduler-service/src/main/java/com/spotify/styx/StyxScheduler.java#L693-L699

@brendandburns
Copy link
Contributor

Closing in favor of #168 that better captures the intent of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants