java icon indicating copy to clipboard operation
java copied to clipboard

It's too hard to manually build a Kubeconfig without a file.

Open syonchao opened this issue 8 years ago • 8 comments

kubernetes-client/java how to use the three file, apiserver-key.pem,apiserver.pem,ca.pem to request https port 6443?

syonchao avatar Oct 31 '18 07:10 syonchao

It's not as awesome as it could be, but you need to use this constructor here:

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

You need to make the list of users be a Map<String, String>

The code around here:

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

will help you figure out what the map of key/value pairs needs to look like.

brendandburns avatar Nov 02 '18 05:11 brendandburns

Alternatively, if you have a kubeconfig YAML file that points to those certificates, you can just load that from file.

brendandburns avatar Nov 02 '18 05:11 brendandburns

If you don't really need a Kubeconfig object but just an ApiClient you can use to communicate with your cluster then use standard Java to load the content of your files and then use something like this:

new ClientBuilder()
    .setBasePath("https://<APISERVER>:6443")
    .setCertificateAuthority(<CA.PEM>)
      .setAuthentication(new ClientCertificateAuthentication(
              <APISERVER.PEM>,
              <APISERVER-KEY.PEM>)).build()

dennis-benzinger-hybris avatar Nov 08 '18 13:11 dennis-benzinger-hybris

I think https://github.com/kubernetes-client/java/issues/429 is relevant too.

asarkar avatar Nov 09 '18 02:11 asarkar

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Apr 26 '19 20:04 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar May 26 '19 21:05 fejta-bot

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Jun 25 '19 22:06 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jun 25 '19 22:06 k8s-ci-robot