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).
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.
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).