i should get the IP of all the Pods of the kubernetes.
I tried to try it with the provided java API, but I get a java.lang.NullPointerException.
https://github.com/kubernetes-client/java/
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Is there any way to get the IP of all running pods in real time?
Use ApiClient client = Config. fromConfig(kubeconfigFilePath)
instead of using ApiClient client = Config.defaultClient();
In general kubeConfigFilePath
is $HOME/.kube/config
.