<p>I'm using Traefik 2.7.0 on an AKS Kubernetes Cluster 1.22.6.
Currently, everything routes to the same service:</p>
<pre><code>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

</code></pre>
<p>I'm currently in the process of externalizing an API resource from this service to a dedicated new service (&quot;/users&quot;) because there will be other services in the future that will need the same functionality.</p>
<p>What I'm trying (and failing) to do, is to route calls to &quot;/users&quot; to the new service:</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: api
  namespace: namespace1
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`api.my-domain.com`) &amp;&amp; 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

</code></pre>
<p>I tried <code>Path(..)</code> and <code>PathPrefix(..)</code>. 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.</p>
<p>Adding the priority manually didn't help either:</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: api
  namespace: namespace1
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`api.my-domain.com`) &amp;&amp; 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

</code></pre>
<p>Am I Missing something here? Any help is appreciated!</p>
<p>Thanks,</p>
<p>best regards,</p>
<p>Pascal</p>

<p>You can only expose services in the same namespace as your IngressRoute resource. If you watch the logs of your Traefik pod when you deploy your IngressRoute, you should see something like:</p>
<blockquote>
<p>time=&quot;2023-01-26T13:57:17Z&quot; level=error msg=&quot;service namespace2/users-api not in the parent resource namespace namespace1&quot; providerName=kubernetescrd ingress=namespace1 namespace=namespace1</p>
</blockquote>
<p>To do what you want, you need to create two separate IngressRoute resources, one in <code>namespace1</code> and one in <code>namespace2</code>.</p>
<p>In <code>namespace1</code>:</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  labels:
    app: old-api
  name: old-api
  namespace: namespace1
spec:
  entryPoints:
  - web
  routes:
  - kind: Rule
    priority: 1000
    match: Host(`api.my-domain.com`)
    services:
    - name: old-api
      port: 80
</code></pre>
<p>In <code>namespace2</code>:</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  labels:
    app: new-api
  name: new-api
  namespace: namespace2
spec:
  entryPoints:
  - web
  routes:
  - kind: Rule
    priority: 2000
    match: Host(`api.my-domain.com`) &amp;&amp; PathPrefix(`/users`)
    services:
    - name: new-api
      port: 80
</code></pre>
<p>You can find all the files I used to test this configuration <a href="https://github.com/larsks/so-example-75218872-traefik-ingress" rel="nofollow noreferrer">here</a>.</p>
<p>I don't know if the explicit priorities are necessary or not; it worked for me without them but maybe I was just lucky so I left them there. I would generally assume that a &quot;more specific route&quot; takes precedence over a &quot;less specific route&quot;, but I don't know if that's actually true.</p>
