Java - Kubernetes find services by label

Viewed 2131

I'm trying to develop a sample application using spring cloud and minikube which consist of 3 spring boot applications.

The first two are two different application (servers) which have the same endpoint but different functionality, and the third one is a client used to integrates the two other applications into one single exposed api.

I managed to deploy all three applications in minikube and managed to develop the full stack and make them communicate between each other, but now I want to go a step further and make the discovery of the two servers automatically, without hard coding the service names.

I deployed the two servers in minikube using the same label and would like to find something so that the client is able to find the services related to the two server apps automatically. This will allow expanding the application easily, so that when I add a new server to the stack the client will find it and expose it without need of any change.

Using Netflix Eureka this can be easily achieved by using something like

discoveryClient.getInstances("service-name").forEach((ServiceInstance s)

But I do no want to add an extra eureka server to the list of microservices since we are going to use kubernetes.

Is there any library which gives this functionality for kubernetes?

2 Answers
Related