How to access each other between k8s and microservices

1/3/2019

Using K8S deployment, our project is based on springcloud. I want to know that in K8S, because the multi-node deployment passes the default host name of the registry, the gateway is deployed in A, and the config is deployed in B. They can't access each other through eureka before. I changed to eureka.instance.prefer-ip-address: true, but I found that they can only access each other on the same host. He is not using cluster-ip of K8S. I want to know how to access each other between services in K8S.

-- Calm
kubernetes
spring-cloud

2 Answers

1/5/2019

In version 7-201712-EA of Activiti Cloud we provided an example using services running the netflix libraries in kubernetes - the stable github tags and docker images are available to refer to. We approached it by creating Kubernetes Services for each component and getting the component to register with eureka using the k8s service name.

To make sure the component declared the correct service name to eureka we set the eureka.instance.hostname in the component, which can be set in the Deployment yaml by specifying an environment variable or using the default environment variable EUREKA_INSTANCE_HOSTNAME. We also kept thing simple by using the same port for the java app in the Pod and for the Service. Again this can be set to match by setting the port in the Pod spec and passing the SERVER_PORT environment variable to the spring boot app.

-- Ryan Dawson
Source: StackOverflow

1/5/2019

Check the spring-cloud-kubernetes project

-- salaboy
Source: StackOverflow