Watch API v11.0.0
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.
Sounds good to me, we'd be glad to take the PR.
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 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());