Can't redirect Path or PathPrefix to another service

Hi!

I'm using Traefik 2.7.0 on an AKS Kubernetes Cluster 1.22.6.
Currently, everything routes to the same service:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: api
  namespace: namespace1
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`api.my-domain.com`)
      kind: Rule
      services:
        - name: api
          namespace: namespace1
          port: 80
  tls:
    secretName: api-my-domain-com-cert

I'm currently in the process of externalizing an API resource from this service to a dedicated new service ("/users") because there will be other services in the future that will need the same functionality.

What I'm trying (and failing) to do, is to route calls to "/users" to the new service:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: api
  namespace: namespace1
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`api.my-domain.com`) && Path(`/users`)
      kind: Rule
      services:
        - name: users-api
          namespace: namespace2
          port: 80
    - match: Host(`api.my-domain.com`)
      kind: Rule
      services:
        - name: api
          namespace: namespace1
          port: 80
  tls:
    secretName: api-baywa-lusy-com-cert

I tried Path(..) and PathPrefix(..). No success. Everything is still routed to the old service. The new service has slightly different output. So I can tell with certainty that it's still routed to the old service.

Adding the priority manually didn't help either:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: api
  namespace: namespace1
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`api.my-domain.com`) && Path(`/users`)
      kind: Rule
      priority: 2000
      services:
        - name: users-api
          namespace: namespace2
          port: 80
    - match: Host(`api.my-domain.com`)
      kind: Rule
      priority: 1000
      services:
        - name: api
          namespace: namespace1
          port: 80
  tls:
    secretName: api-baywa-lusy-com-cert

Am I missing something here? Any help is appreciated!

N.B. This is my first post here. I apologize in advance if it's the wrong place for this kind of question.

Thanks,
best regards,
Pascal

Problem solved:

The IngressRoute must be in the same namespace than the service it addresses.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.