We are working a lot with Kubernetes lately and were looking for a Java API to integrate our dashboards with Kubernetes. There used to be a few libraries to choose from, but most are not actively maintained and are still using the depricated beta APIs.
The library which is part of Fabric8 seems to be the best/only option, but unfortunatly the library’s dependency graph is huge mess. This is always bad, you should be very weary if Maven/Gradle tries to pull in half of Maven central, but it’s even worse when working in a modular environemnt like OSGi. We started out as we always do with these kind of libraries: wrapping them in a self contained bundle to at least hide the mess. This didn’t work out very well, there is just no end to the list of (transitive) dependencies.
So we decided to build something ourselves, and decided to open source it as part of Amdatu. As with every new Amdatu component it will first live in the “labs” incubator until we decide it’s stable and useful enough to make it to amdatu.org.
Introducing Amdatu Kubernetes
The Amdatu Kubernetes API makes it easy to use Kubernetes from OSGi or Java in general.
In a non-OSGi Java application you pass the Kubernetes API url to the constructor of the KubernetesRestClient.
The API is based on RX Observables. This makes it easier to deal with the asynchronous nature of the API.
The model classes used by Amdatu Kubernetes are from the Fabric8 project. These are generated from the JSON schema provided by Kubernetes, so there was no point in re-doing this.
The integration tests in the project are the best place to learn how to use the API. Configure the test suite with a Kubernets API url and it will create a test namespace with a ReplicationController and Pods and executes several operations on them.
The Kubernetes API is not (yet) fully covered by Amdatu Kubernetes, but the most important methods are, including watches. Of course pull requests are welcome!