'Why my Kubernetes Services are not connecting?

I have 3 services running on Kubernetes (front, nodejs server and a mysql database). The first service is of type load Balancer and runs the front-end (angular) of the web app with an external ip address. The second service runs the nodejs server with type ClusterIP and the third service is of type ClusterIP and runs mysql.

The connection between the nodejs service and the database works perfect. The problem is the connection between the front service and the nodejs service in Kubernetes. When the nodejs service type is ClusterIP the API calls are this way (and doesnt work: throw me time out):

export class TareasService {

  constructor(private http: HttpClient) { }

  getTareas(){
    return this.http.get('http://<NODEJS-SERVICE-CLUSTERIP>:3000/api/tareas/'); 
  }

  getTarea(id:string){
    return this.http.get('http://<NODEJS-SERVICE-CLUSTERIP>:3000/api/tareas/'+ id);
  }

  saveTarea(tarea:Tarea){
    return this.http.post('http://<NODEJS-SERVICE-CLUSTERIP>:3000/api/tareas',tarea);
  }
...

But if I change the type of the nodejs kubernetes service to load Balancer and set the API calls this way:

export class TareasService {

  constructor(private http: HttpClient) { }

  getTareas(){
    return this.http.get('http://<NODEJS-SERVICE-EXTERNALIP>:3000/api/tareas/'); 
  }

  getTarea(id:string){
    return this.http.get('http://<NODEJS-SERVICE-EXTERNALIP>:3000/api/tareas/'+ id);
  }

  saveTarea(tarea:Tarea){
    return this.http.post('http://<NODEJS-SERVICE-EXTERNALIP>:3000/api/tareas',tarea);
  }
...

It works perfectly. The documentation says that the Cluster IP is accessible from anything inside the cluster, which is the case. Why doesnt work? Is there any other option that doesn't expose the service?

List of the services when its working:

kubectl get svc

--edit:

The docker image of the node js server:

FROM node:16-alpine

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .
WORKDIR /usr/src/app/build
CMD [ "node", "index.js" ]


and the yaml as ClusterIP by default:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs-poc
  labels:
    app: api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - name: api
        image: my-image
        imagePullPolicy: IfNotPresent
---
apiVersion: v1
kind: Service
metadata:
  name: nodejs-poc
  labels:
    app: api
spec:
  selector:
    app: api
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source