skip to Main Content

I have my services deployed on aks, where one of the services frontend is exposed using load-balancer and frontend is suppose to request data from 2 different micro services, but I am not able to receive data on the website.

Also I tried to request directly to the ingress,considering i was doing something wrong in the frontend still i got 404 error.

my ingress resource file looks something like this:

    • apiVersion: networking.k8s.io/v1
      kind: Ingress
      metadata:
        name: bert-ingress  namespace: default
        annotations:
          nginx.ingress.kubernetes.io/rewrite-target: /
      spec:
        ingressClassName: nginx
        rules:
        - http:
            paths:
            - path: /reinforcement
              pathType: Prefix
              backend:
                service:
                  name: bertreinforcement
                  port:
                    number: 5000
            - path: /environment
              pathType: Prefix
              backend:
                service:
                  name: bertenvironment
                  port:
                    number: 8080
      
      

all my ports and names are fine.

Here is the request i tried sending: 
(base) b:~$ curl -I http://<IngressIP>/reinforcement/get_prediction_result
HTTP/1.1 404 Not Found
Date: Tue, 13 Aug 2024 05:44:26 GMT
Content-Type: text/html
Content-Length: 146
Connection: keep-alive

(base) b:~$ curl -I http://<IngressIP>/environment/get_result
HTTP/1.1 404 Not Found
Date: Tue, 13 Aug 2024 05:44:39 GMT
Content-Type: text/html
Content-Length: 146
Connection: keep-alive

similar response for other micro service also, my code has the endpoint correctly set,
what can be the reason? I am doing this for the first time, is this related to ingress resource file? or is it something related to wrong procedure of exposing my internal ,micro services?

2

Answers


  1. Chosen as BEST ANSWER

    The issue is resolved was a small issue with the specific path mentioned in the backend, i just put the endpoint here and it worked, thanks.

        apiVersion: networking.k8s.io/v1
        kind: Ingress
        metadata:
          name: bert-ingress  namespace: default
          annotations:
            nginx.ingress.kubernetes.io/rewrite-target: /
        spec:
          ingressClassName: nginx
          rules:
          - http:
              paths:
              - path: /get_prediction_result
                pathType: Prefix
                backend:
                  service:
                    name: bertreinforcement
                    port:
                      number: 5000
              - path: /get_result
                pathType: Prefix
                backend:
                  service:
                    name: bertenvironment
                    port:
                      number: 8080
    

    this worked


  2. The issue, I can see is this bit- nginx.ingress.kubernetes.io/rewrite-target annotation rewrites the URL path before forwarding it to the backend service, which can lead to 404 errors if not configured correctly.

    Hence I am going to assume – which is you don’t intend to rewrite paths in this case simply removing this bit below should solve the problem.

      annotations:
        nginx.ingress.kubernetes.io/rewrite-target: /   <- remove from your yaml
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search