PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, August 13, 2022

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

 August 13, 2022     ingress-controller, kubernetes-ingress, nginx-ingress, quarkus     No comments   

Issue

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


Answered By - Bilel-NEJI
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing