Can’t communicate between pods in Kubernetes

by admin
Reading Time: < 1 minute

I’m trying to connect two express apps to communicate with each other. Each app is deployed in a different Pod.
I’m trying to use a ClusterIP service to make a req from Pod 1 to Pod 2.

Say pod 1 has an axios.post(‘http://pod-2-clusterip-service:4005’, data), and Pod 2 has ClusterIP service config that looks like this:

apiVersion: v1
kind: Service
metadata: 
  name: pod-2-clusterip-service
spec: 
  selector:
   app: pod2
  ports:
    - name: pod2
      protocol: TCP
      port: 4005
      targetPort: 4005

Both pods seems to be up and running, when i do kubectl logs i can see that. Problem is, when I run this request from Pod 1 (through postman to NodePort service, i get:

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

<ref *1> Error: connect ECONNREFUSED 10.110.68.128:4005
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
  errno: -111,
  code: 'ECONNREFUSED',

And the app inside Pod 1 is crashing. Someone has an Idea what can it be?
I tried restarting the services and pods… didn’t help.

    Related Posts

    Leave a Comment