Search code examples
kubernetes-ingressquarkusnginx-ingressingress-controller

How to configure ingress controller with multiple paths for the same service?


I have a separate ingress-internal (manifests) for the backend and the frontend. My backend service has several endpoints: one with GraphqQL and two Rest. After deploying the project, I find that when I request the Rest endpoint (POST request); I have the error code 404.

How can I configure properly the backend ingress manifest?

I tired too many annotations like: nginx.ingress.kubernetes.io/use-regex: "true" # nginx.ingress.kubernetes.io/app-root: / # nginx.ingress.kubernetes.io/default-backend: mcs-thirdparty-backend nginx.ingress.kubernetes.io/rewrite-target: /$2 # nginx.ingress.kubernetes.io/rewrite-path: /response # nginx.ingress.kubernetes.io/preserve-trailing-slash: "true"

This is my current backend's ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mcs-thirdparty-back-ingress
  namespace: namespace
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx-internal
  rules:
  - host: backend.exemple.com
    http:
      paths:
      - path: '/(/|$)(.*)'
        backend:
          service:
            name: mcs-thirdparty-backend
            port:
              number: 8080
        pathType: Prefix

Solution

  • This the backend ingress that I arrived to work successfullywith:

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: mcs-thirdparty-ingress
      namespace: namespace
    spec:
      ingressClassName: nginx-internal
      rules:
      - host: bilels.exemple.com
        http:
          paths:
          - path: /
            backend:
              service:
                name: mcs-thirdparty-frontend
                port:
                  number: 80
            pathType: Prefix