What's the Kubernetes Client-Java API to get all deployments

5/23/2018

I've been exploring the Kubernetes-Client/Java library and I can't figure out the API call to get all the deployments.

I'm looking for the K8-Client/Java API call for this command:

kubectl get deployments
NAME             DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
appservice1       3         3         3            3           5d
appservice2       3         3         3            3           1d
appservice3       1         1         1            1           22d

More specifically, I'm interested in determining the number of desired & current pods for each deployment (like above).

-- BlueChips23
java
kubernetes
kubernetes-health-check

2 Answers

5/23/2018

You can find all methods of the kubernetes java client here: https://github.com/kubernetes-client/java/tree/master/kubernetes/docs

What you're searching for is the listNamespacedDeployment or listDeploymentForAllNamespaces.

The return type of those methods is AppsV1beta1DeploymentList so you'll find the AppsV1beta1DeploymentStatus which is containing all information about the current number of pods controlled by the deployment.

-- alexandrevilain
Source: StackOverflow

9/9/2018

There is another kubernetes jave client and here is the example of deployments

Note the official library is generated by swagger and not well organized (I think).

-- Leon
Source: StackOverflow