How Service Discovery of Kubernate can be used for SpringBoot applications

7/4/2018

Consul can be used for service discovery in Springboot applications. I am new to Kubernates and found Kubernates also has service discovery functionality. I searched how this service discovery can be used like consul but could not find any. All I found was, service discovery for pods is available in K8s. Anyone let me know how this service discovery of Kubernates can be used for Springboot applications deployed in pods for inter communication so that consul can be avoided.

-- Débora
kubernetes
service-discovery
spring-boot

2 Answers

7/6/2018

Look into using a Service per Spring Boot application deployment.

In case all Spring Boot applications and their clients are running on the same Kubernetes cluster, the Services can be created as type ClusterIP. Clients simply use the Service name as the host name in the application's endpoint URL, and Kubernetes will take care of routing the calls to an available application instance; clients need not to know on which node the application pods are running in the cluster or how many instances are running.

In case clients are external to the Kubernetes cluster, the respective Service has to be exposed outside of the cluster. See https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types for which service types can be used in this case.

-- apisim
Source: StackOverflow

7/4/2018

If you are not bound use Consul is possible use directly Kubernetes service registry that is based on Etcd. If you make some research around "spring boot + service registry kubernetes" you can find some useful example

-- fbalicchia
Source: StackOverflow