java icon indicating copy to clipboard operation
java copied to clipboard

Watch API v11.0.0

Open brian-singer opened this issue 5 years ago • 3 comments

okhttp3 versions X and newer you need to always set the 1_1 for Kubernetes APIs like is done in the ClientBuilder:

    client.setHttpClient(
        client.getHttpClient().newBuilder().protocols(Arrays.asList(Protocol.HTTP_1_1)).build());

however, there is a problem in SharedInformerFactory. You have to be sure you set the static default client or else you get an SSL Handshake problem when calling the watch API.

This is a known problem with newer openjdk versions and the default okhttp3 client using HTTP2.

In order to fix the problem I did this:

        ApiClient apiClient = ClientBuilder.cluster().build();
        Configuration.setDefaultApiClient(apiClient);

which forced the HTTP_1_1 for the default client and fixed the default client used in the SharedInformerFactory.

I would consider changing the static Configuration class to use a configuration similar to the ClientBuilder.build()

I will add a pull request if needed.

brian-singer avatar Feb 23 '21 12:02 brian-singer

Sounds good to me, we'd be glad to take the PR.

brendandburns avatar Feb 23 '21 17:02 brendandburns

default client used in the SharedInformerFactory.

@brian-singer the informer-factory can also use a specified ApiClient, i dont think you have to explicitly pin the static ApiClient instance if the proper constructor was used.

https://github.com/kubernetes-client/java/blob/6a4b5fe0b659beb6bfbacfd8ebaa816d0a3b7f8d/util/src/main/java/io/kubernetes/client/informer/SharedInformerFactory.java#L55

yue9944882 avatar Feb 24 '21 07:02 yue9944882

@yue9944882 good call! I did exactly that and is a perfect solution for the problem in my case :)

final SharedInformerFactory informerFactory = new SharedInformerFactory(ClientBuilder.cluster().build());

brian-singer avatar Feb 25 '21 19:02 brian-singer