How to get all Pod's IP on a kubernetes

11/2/2018

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?

-- 김태우
kubernetes

1 Answer

11/2/2018

Use ApiClient client = Config. fromConfig(kubeconfigFilePath) instead of using ApiClient client = Config.defaultClient();

In general kubeConfigFilePath is $HOME/.kube/config.

-- Shudipta Sharma
Source: StackOverflow