0

I want to implement the next rules. I have two services which are pointing to different pods. I have a path /rest-api and /rest-api/topology. I want to point one of them to a svc and another one to a different one.

Here is my attempt, but it seems something is wrong.

spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: writer-svc
            port:
              number: 8443
        path: /rest-api(/topology|$)(.*)
        pathType: Prefix
      - backend:
          service:
            name: normal-svc
            port:
              number: 8443
        path: /rest-api(/|$)(?!topology|$)(.*)
        pathType: Prefix
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Since this code doesn't produce any errors, more details than "something is wrong" would be nice, because depending on what you use this ingress with, "wrong" can take many forms. – Randych Feb 07 '23 at 11:57
  • so originaly there was just 1 block with /rest-api(/|$)(.*) which is working just fine, if i add 1 more block which it will point to another svc i will got 500 error code – Alin-Bogdan Zirbo Feb 07 '23 at 13:00
  • Doesn't sound right. I've been doing different combos with ingress, even making different services for same app, and it all worked – Randych Feb 07 '23 at 13:43

1 Answers1

0

Here's my normal approach:

spec: 
  ingressClassName: alb
  rules:
  - host: my.server.co
    http:
      paths:
      - path: /api/
        pathType: Prefix
        backend: 
          service:
            name: yeaboi1
            port:  
              number: 80
      - path: /api/coolstuff
        pathType: Prefix
        backend: 
          service:
            name: yeaboi2
            port:  
              number: 80

Works just fine. The obvious difference I see from yours is absence of unneeded regex. Maybe try it this way?

Randych
  • 56
  • 5
  • i did a try without regex but still when i have 2 blocks i will get 500 – Alin-Bogdan Zirbo Feb 07 '23 at 13:07
  • Doesn't sound like ingress problem. What does happen when you have just the other service? Still 500? If so, is there anything in logs for pods related to that service? – Randych Feb 07 '23 at 13:42
  • if just the one with rest-api all good,but i found the issue, is related to rewrite-target annotation. which is /rest-api/$2 butbecause i dont use nginx plus where i can have multiple rewrite dependent on the svc i just created a new ingress and that's it. thanks for help – Alin-Bogdan Zirbo Feb 07 '23 at 13:54
  • Glad I could help. And should've asked for ingress yaml outright. Rewrite-target is quite unfriendly and can easily break stuff. – Randych Feb 07 '23 at 15:32