0

I am using the Fabric8 Java library to access the Kubernetes API within an actor system. I am concerned about connection leaks and want to understand how the client connections are closed underneath after a REST call is made

Here is the code that initializes the client:

config = new ConfigBuilder()
  .withMasterUrl(apiServer)
  .withOauthToken(token)
  .withTrustCerts(true)
  .build();
client = new DefaultKubernetesClient(config);

This client is then passed on to various actors, how should I be closing these connections in the actors so that connections don't leak or are abandoned hen a certain actor dies?

Rohan Kumar
  • 5,427
  • 8
  • 25
  • 40
user_mda
  • 18,148
  • 27
  • 82
  • 145

2 Answers2

3

The client object has a close method on it.

So, it should be something like client.close().

iocanel
  • 570
  • 2
  • 2
-1

ReST is the underlying protocol. There's no persistent connection to the server when you create the client. It's only there to help keep configuration together for the calls.

Lev Kuznetsov
  • 3,520
  • 5
  • 20
  • 33
  • Thanks Lev, is there any documentation on this? I came across an okhttp dependency and assumed it uses it for making api calls? Also isnt REST done over HTTP? – user_mda Mar 09 '18 at 18:53
  • Yes ReST is over http. For every call the fabric library makes it just makes an http call with the right certificates and so on. You can make these calls yourself and the ReST API is documented. You can also look at sources of the fabric library - the library is autogenerated from the API spec – Lev Kuznetsov Mar 09 '18 at 20:25
  • 1
    Under the hood a the kubernetes-client is using an okhttp connection pool. To properly cleanup you need to call the close method, that also evicts all connection from the pool, and shutdowns the internal okhttp executor. – iocanel Mar 13 '18 at 07:37