Get k8s service endpoints using kubernetes java client

2/16/2020

I have my Kubernetes client which does this

public class Example {
    public static void main(String[] args) throws IOException, ApiException{
        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()) {
        String generateName = item.getMetadata().getGenerateName();
            // if generated name that I need > get IP
        }
    }
}

In above example I can get all pods per namespace, per state, and get the IP of certain pod.

My question - is there any possibility not to go over all pods in namespace, but get ONLY endpoints of certain service?

-- liotur
deployment
kubernetes
kubernetes-cluster
kubernetes-helm

0 Answers