How to communicate between two pods with nodejs application

6/23/2019

I have two nodejs application, one as fronted and one ad backed. I am trying to run the application using kubernetes and not sure what to mention in serverProxy to connect to api which is running in different pod.

serverProxy: {
    apiA: process.env.API_A_PROXY || "https://localhost:4200"
}

What should i mention in above code of frontend node application

-- Tarun Mittal
containers
kubernetes
kubernetes-pod
pod

1 Answer

6/23/2019

If your application is a real frontend, then it does not run in a pod, it runs in clients browser, and is only served from a pod. In that case you need to expose your api either with LoadBalancer type Service or via Ingress.

In case of LB Service you will point your app to http://<lb_ip>:<port>. In case of ingress, you will have to provide a DNS name pointing to LB IP of Ingress Controller, and then point your app to that name.

If that were only about pod-to-pod communication, then you should use ClusterIP type service and point to that service name which will be resolved within cluster ( Pod A -> Service B -> Pod B )

-- Radek 'Goblin' Pieczonka
Source: StackOverflow