0

I deployed a MERN stack app on a minikube cluster all the pod are running fine

but I tried to access the backend from the fronted app and I am getting error refused connection

What could cause this?

nodejs-deployment.yml

This is the deployment that creates the pod with the environmental variables

apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
  labels:
    app: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend
          image: arch-backend:1.0
          ports:
            - containerPort: 7500
          env:
            - name: ME_CONFIG_MONGODB_ADMINUSERNAME
              valueFrom:
                secretKeyRef:
                  name: mongodb-secret
                  key: mongo-db-username
            - name: ME_CONFIG_MONGODB_ADMINPASSWORD
              valueFrom:
                secretKeyRef:
                  name: mongodb-secret
                  key: mongo-db-password
            - name: ME_CONFIG_MONGODB_SERVER
              valueFrom:
                configMapKeyRef:
                  name: nodejs-configmap
                  key: database_url
          imagePullPolicy: IfNotPresent

nodejs-service.yml

apiVersion: v1
kind: Service
metadata:
  name: backend
spec:
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 7500
      targetPort: 7500

frontend.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
  labels:
    app: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
        - name: frontend
          image: arch-frontend:1.0
          ports:
            - containerPort: 80
          env:
            - name: REACT_APP_DEV_BASE_URL
              value: backend
          imagePullPolicy: IfNotPresent

---
apiVersion: v1
kind: Service
metadata:
  name: frontend
spec:
  selector:
    app: frontend
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 80
      nodePort: 30012

Output of kubectl get svc -o wide

NAME              TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE   SELECTOR
backend           ClusterIP      10.99.138.189    <none>        7500/TCP         44h   app=backend
frontend          LoadBalancer   10.110.160.225   <pending>     3000:30012/TCP   44h   app=frontend
kubernetes        ClusterIP      10.96.0.1        <none>        443/TCP          45h   <none>
mongodb-service   ClusterIP      10.96.50.66      <none>        27017/TCP        44h   app=mongodb
etranz
  • 891
  • 2
  • 10
  • 29
  • Is the frontend application actually running in your browser (even if it's served from a container)? The browser is outside the cluster and browser-based applications can't see the ClusterIP Service names. – David Maze Apr 16 '23 at 11:17
  • REACT_APP_DEV_BASE_URL should be http://backend:7500 . Logicaly is http://,:PORT – Klevi Merkuri Apr 16 '23 at 21:53

0 Answers0