Search code examples
eclipsekubernetesservice-discoverykube-dns

How to connect local java service to remote kubernetes services


I am working as DevOps engineer on Kubernetes and spring cloud micro-services.

The problem I am asking about is if I have a development environment that runs some micro-services on kubernetes cluster (micro-services can interconnect each other using kube-dns) and I have some other micro-services running locally (which developer works on in eclipse IDE) in order to make some tests.

These micro-services running locally need to join the other ones running on the cluster to do the exact job. How may I resolve that issue?


Solution

  • There are two ways to go about this : expose the services you need to connect to to the public (NodePort/LB/Ingress) or make it possible for the developers to actually reach inside your cluster so they can connect to these services.

    The first one should be easy with something like NginX IngressController and vhost based exposing of services (you can also protect them with ie. basic auth).

    The second one can be done with ie. Weave Net (if that is/can be the overlay network you use). If you connect your devs to the central k8s cluster like this, they will only need to run kube-proxy on their nodes and point containers to k8s DNS. Obviously this is something I would advise only in case of dev/stage clusters and not for prod.