-
Notifications
You must be signed in to change notification settings - Fork 26
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
Created kubernetes client from openapi spec #762
Conversation
Work in progress - adding kubernetes client
protected DefaultHttpClient getKubernetesHttpClient() { | ||
URI uri = URI.create(kubeConfig.getCluster().server()); | ||
|
||
return new DefaultHttpClient(LoadBalancer.fixed(uri), |
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 will replace this with http client builder once micronaut-core 4.7.0 gets released
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.
Can this code now use HttpClientRegistry.getClient
? Maybe we need to enhance that API to avoid references to these internal APIs? @yawkat WDYT?
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.
HttpClientRegistry.getClient
can't be used since we need a custom implementation of NettyClientSslBuilder (which is KubernetesClientSslBuilder). Once micronaut-core 4.7.0 gets released entire constructor will be replaced with just a few lines where we set KubernetesClientSslBuilder
...penapi/src/main/java/io/micronaut/kubernetes/client/openapi/ssl/DefaultPrivateKeyLoader.java
Outdated
Show resolved
Hide resolved
...s-client-openapi/src/main/java/io/micronaut/kubernetes/client/openapi/config/KubeConfig.java
Outdated
Show resolved
Hide resolved
...main/java/io/micronaut/kubernetes/client/openapi/credential/ExecCommandCredentialLoader.java
Outdated
Show resolved
Hide resolved
i didnt look too much at the k8s specific parts since i am not familiar with it |
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.
Looks like a good start, needs documentation
testImplementation(mn.micronaut.http.server.netty) | ||
} | ||
|
||
tasks.register("prepareOpenapiSpec") { |
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.
@melix can you review this Gradle logic?
...penapi/src/main/java/io/micronaut/kubernetes/client/openapi/KubernetesHttpClientFactory.java
Outdated
Show resolved
Hide resolved
protected DefaultHttpClient getKubernetesHttpClient() { | ||
URI uri = URI.create(kubeConfig.getCluster().server()); | ||
|
||
return new DefaultHttpClient(LoadBalancer.fixed(uri), |
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.
Can this code now use HttpClientRegistry.getClient
? Maybe we need to enhance that API to avoid references to these internal APIs? @yawkat WDYT?
registry.add(MediaType.APPLICATION_JSON_TYPE, new NettyCharSequenceBodyWriter()); | ||
registry.add(MediaType.APPLICATION_JSON_STREAM_TYPE, new NettyJsonStreamHandler<>(mapper)); | ||
return registry; | ||
} |
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.
would like to see how we can avoid this logic and recreating all these objects? //cc @yawkat
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.
All those will be removed once micronaut-core 4.7.0 gets released since that version contains http client builder implementation
...api/src/main/java/io/micronaut/kubernetes/client/openapi/ssl/KubernetesClientSslBuilder.java
Outdated
Show resolved
Hide resolved
...api/src/main/java/io/micronaut/kubernetes/client/openapi/ssl/KubernetesClientSslBuilder.java
Outdated
Show resolved
Hide resolved
...api/src/main/java/io/micronaut/kubernetes/client/openapi/ssl/KubernetesClientSslBuilder.java
Show resolved
Hide resolved
...api/src/main/java/io/micronaut/kubernetes/client/openapi/ssl/KubernetesPrivateKeyLoader.java
Outdated
Show resolved
Hide resolved
null, | ||
null, | ||
null, | ||
null) |
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.
wonder if there is a way to get the OpenAPI generator to generate overloaded variants that pass null
to avoid having to write code like 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.
@andriy-dmytruk - do you maybe know answer to Graeme's above question?
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 the only method signature that we generate. So far we just assume that calling a method is the simplest approach.
I guess we could generate another method that doesn't have any optional parameters. But if someone needs to set one optional parameter, they would need to use the full method and set all the others to null.
The OCI SDK client generates a separate class for each request that has a separate builder that allows ignoring all or some properties for the request. We could have an option to choose what to generate or even generate both. IMO that just complicates everything even 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.
we would need to generate 1 overloaded method per optional parameter and pass null
. So in this case 11 methods would be generated. These could be default
methods.
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.
Note I don't think this should block this PR but we should look to improve later
Added docs. @graemerocher - please review |
…tomized, for example if kube config needs to be loaded from cloud service
...pi/src/main/java/io/micronaut/kubernetes/client/openapi/config/AbstractKubeConfigLoader.java
Outdated
Show resolved
Hide resolved
...pi/src/main/java/io/micronaut/kubernetes/client/openapi/config/AbstractKubeConfigLoader.java
Show resolved
Hide resolved
...api/src/main/java/io/micronaut/kubernetes/client/openapi/config/DefaultKubeConfigLoader.java
Show resolved
Hide resolved
...api/src/main/java/io/micronaut/kubernetes/client/openapi/config/DefaultKubeConfigLoader.java
Show resolved
Hide resolved
...s-client-openapi/src/main/java/io/micronaut/kubernetes/client/openapi/config/KubeConfig.java
Outdated
Show resolved
Hide resolved
...nt-openapi/src/main/java/io/micronaut/kubernetes/client/openapi/config/KubeConfigLoader.java
Show resolved
Hide resolved
...main/java/io/micronaut/kubernetes/client/openapi/credential/ExecCommandCredentialLoader.java
Outdated
Show resolved
Hide resolved
...penapi/src/main/java/io/micronaut/kubernetes/client/openapi/ssl/DefaultPrivateKeyLoader.java
Show resolved
Hide resolved
@graemerocher - I also implemented the service account authentication in this PR: 124d9ac |
…netes into kubernetes-client-openapi
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
No description provided.