2

On AWS, EKS with classical load balancer from https://github.com/kubernetes/ingress-nginx, 0.32.0 Similar to Kubernetes Ingress non-root path 404 Not Found , I'm getting 404 when forwarding a service with path: [ anything other that / ].

When forwarding with path: / , everything works, but I need to expose several services that are all giving me the same issue.

My service and deployment:

apiVersion: v1
kind: Service
metadata:
  name: appointments-api
  labels:
    app: appointments-api
spec:
  ports:
  - port: 80
  selector:
    app: appointments-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: appointments-api
  labels:
    app: appointments-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: appointments-api
  template:
    metadata:
      labels:
        app: appointments-api
    spec:
      containers:
      - name: appointments-api
        image: ....ecr.us-west-2.amazonaws.com/appointments_api
        ports:
        - containerPort: 80
        envFrom:
          - configMapRef:
              name: env-app-con

My ingress:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: appointments
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /appoint
        backend:
          serviceName: appointments-api
          servicePort: 80

now, looking here: https://kubernetes.github.io/ingress-nginx/examples/rewrite/#deployment and running this:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: appointments
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
  - http:
      paths:
      - path: /appoint(/|$)(.*)
        backend:
          serviceName: appointments-api
          servicePort: 80

I can get to the front page of a aspnet application, but various resources can't be reached (e.g. "Fetch error Not Found /swagger/v1/swagger.json")

I'm stumped, not sure if it's an application issue or nginx, and how to configure them.

Nahshon paz
  • 4,005
  • 2
  • 21
  • 32
  • This seems to be a swagger behind a reverse proxy issue. For now the rewrite-target: /$2 and - path: /appoint(/|$)(.*) allows for API to run and that's fine, just too bad we cant have GUI – Nahshon paz Jun 15 '20 at 07:17
  • So how is your GUI deployed and exposed ? I see in your question only the `Deployment` and the `ClusterIP Service` for exposing `appointments-api`. – mario Jun 26 '20 at 11:33
  • look a little closer @mario ... – Nahshon paz Jun 28 '20 at 07:55
  • Could you please provide curl request examples to the ingress (and to LB) and expected path on backend services? It could also help if you would add to your question example of successful curl request to the missing resource ( that causes 404 when requesting on the ingress ) from temporary ubuntu pod directly to the backend service in the same cluster to ensure the resources are accessible at the right path. – VAS Jun 29 '20 at 14:38
  • 2
    I noticed that you didn't specify the ingress class annotation `kubernetes.io/ingress.class: "nginx"`. You need it to make sure that you're actually using **nginx-ingress controller**. On aws-eks as far as I know the default option is **aws-alb-ingress-controller** so first of all set the correct ingress class to rule out this is not the reason your rewrites don't work as expected. – mario Jun 29 '20 at 18:21
  • Hello @Nahshonpaz. Have you tried to specify the `ingress.class` as suggested above? – Wytrzymały Wiktor Apr 21 '21 at 12:08
  • @WytrzymałyWiktor never got around to it, no – Nahshon paz Apr 28 '21 at 06:30

0 Answers0