
Java client library for the Kubernetes API, enabling programmatic management of clusters, pods, deployments, and other resources with support for authentication, watch, exec, and port-forward operations.
Java client for the kubernetes API.
The Java client uses Semantic Versioning. We increment the major version number whenever we regenerate the client for a new Kubernetes release version (see table below). Whenever we do this there are new APIs added and possibly breaking changes in the generated Kubernetes API Stubs. Whenever you upgrade a major version, be prepared for potential breaking changes.
To install the Java client library to your local Maven repository, simply execute:
git clone --recursive https://github.com/kubernetes-client/java
cd java
mvn install
Refer to the official documentation for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>8.0.2</version>
</dependency>
compile 'io.kubernetes:client-java:8.0.2'
At first generate the JAR by executing:
git clone --recursive https://github.com/kubernetes-client/java
cd java/kubernetes
mvn package
Then manually install the following JARs:
We prepared a few examples for common use-cases which are shown below:
kubectl patch.kubectl get <resource> -w.kubectl logs.kubectl exec.kubectl port-forward.kubectl attach.kubectl cp.client-java-extended module)
list all pods:
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodList;
import io.kubernetes.client.util.Config;
import java.io.IOException;
public class Example {
public static void main(String[] args) throws IOException, ApiException{
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);