How to connect frontend and backend in event-drivent architecture on Kubernetes cluster?

All pods and databases are running successfully
I have a login page, with endpoint /login on the frontend service, but it cannot redirect to the rest-service, can everyone help me to fix the problem (I run it successfully on my local machine manually).

  1. This is how I built and deploy my front-end service:

nginx.conf:

worker_processes auto;

events {
    worker_connections 8000;
    multi_accept on;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format compression '$remote_addr - $remote_user [$time_local] '
                           '"$request" $status $upstream_addr '
                           '"$http_referer" "$http_user_agent"';

    server {
        listen 3000;
        access_log /var/log/nginx/access.log compression;

        root /usr/share/nginx/html;
        index index.html index.htm;

        location / {
            try_files $uri $uri/ /index.html;
        }

        # Proxy API requests to backend
        location /api {
            proxy_pass $REACT_APP_BACKEND_HOST;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        # Media: images, icons, video, audio, HTC
        location ~* .(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "public";
        }

        # Javascript and CSS files
        location ~* .(?:css|js)$ {
            try_files $uri =404;
            expires 1y;
            access_log off;
            add_header Cache-Control "public";
        }

        # Any route containing a file extension (e.g. /devicesfile.js)
        location ~ ^.+..+$ {
            try_files $uri =404;
        }
    }
}

Dockerfile:

FROM node:18-alpine as build

WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

entrypoint.sh:

envsubst '$REACT_APP_BACKEND_HOST' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
nginx -g 'daemon off;'
  1. And here is my config on Kubernetes:

rest-client-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: client-frontend
  labels:
    app: client-frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: client-frontend
  template:
    metadata:
      labels:
        app: client-frontend
    spec:
      containers:
      - name: client
        image: daniel135dang/client:1.0.0-6
        ports:
        - containerPort: 3000
        envFrom:
          - configMapRef:
              name: app-config
        env:
        - name: REACT_APP_BACKEND_HOST
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: REACT_APP_BACKEND_HOST
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rest-backend
  labels:
    app: rest-backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rest-backend
  template:
    metadata:
      labels:
        app: rest-backend
    spec:
      volumes:
      - name: rest-file
        persistentVolumeClaim:
          claimName: rest-file-pvc
      - name: google-credentials
        secret:
          secretName: google-credentials
      containers:
      - name: rest-backend
        image: daniel135dang/rest:1.0.0-6
        ports:
        - containerPort: 5000
        volumeMounts:
        - name: rest-file
          mountPath: /mnt/rest/files
        - name: google-credentials
          mountPath: /app/google_credentials.json
          subPath: google_credentials.json
          readOnly: true
        env:
          - name: PORT
            value: "5000"
          - name: APP_NAME
            value: "rest"
          - name: HOST
            value: "rest-service"
          - name: RABBITMQ_HOST
            value: "amqp://rabbitmq:5672"
          - name: RABBITMQ_FILE_LOCATION_EXCHANGE
            value: "uploaded_file_location"
          - name: RABBITMQ_OUTPUT_LOCATION_EXCHANGE
            value: "output_location"
          - name: POSTGRES_HOST
            valueFrom:
              configMapKeyRef:
                name: services-config
                key: POSTGRES_HOST
          - name: POSTGRES_USER
            valueFrom:
              configMapKeyRef:
                name: services-config
                key: POSTGRES_USER
          - name: POSTGRES_PASSWORD
            valueFrom:
              configMapKeyRef:
                name: services-config
                key: POSTGRES_PASSWORD
          - name: POSTGRES_DB
            valueFrom:
              configMapKeyRef:
                name: services-config
                key: POSTGRES_DB
          - name: ROOT_DIR
            valueFrom:
              configMapKeyRef:
                name: services-config
                key: ROOT_DIR
          - name: REACT_APP_SERVICE_LIST
            valueFrom:
              configMapKeyRef:
                name: app-config
                key: REACT_APP_SERVICE_LIST
          - name: GUIDELINES_LIST
            value: "chapter_title,format_check,page_count"
          - name: GOOGLE_CLOUD_STORAGE_BUCKET
            valueFrom:
              configMapKeyRef:
                name: services-config
                key: GOOGLE_CLOUD_STORAGE_BUCKET
---
apiVersion: v1
kind: Service
metadata:
  name: client-frontend-service
spec:
  type: LoadBalancer
  selector:
    app: client-frontend
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: rest-service
spec:
  type: ClusterIP
  selector:
    app: rest-backend
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000

app-config.yml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  REACT_APP_SERVICE_LIST: "word_frequency,chapter_title,format_check,chapter_summarization,page_count,table_of_content,citation,table_figure_detection"
  REACT_APP_BACKEND_HOST: "http://rest-service:5000"

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật