How to connect backend and frontend correctly with same url in Jenkins-x

342 views Asked by At

I use jenkins-x to deploy front-end and back-end projects, and I want to use the same url in ingress with different paths. The frontend uses mysite.com, and the backend uses mysite.com/api. At first, I wanted to directly modify "charts/my-project/template/ingress" to achieve the goal, but when the backend was deployed to gke, he did not Use the correct address, but use the default address of gke, and generate two addresses like .., ../api, I don’t Understand why this happens, is there any good way to solve this problem?

spec:
  rules:
  - host: mysite.com
    http:
      paths:
      - path: /api
        backend:
          serviceName: {{ .Values.service.name }}
          servicePort: 8080
1

There are 1 answers

0
Veve On

You can set your frontend and your backend on the same domain like this:

 spec:
   rules:
   - host: mysite.com
     http:
       paths:
       - backend:
           serviceName: <your-frontend-service-name>
           servicePort: 80
         path: /
       - backend:
           serviceName: <your-backend-service-name>
           servicePort: 8080
         path: /api