Middleware don't work with IngressRoute

Issue

I want to use an IngressRoute with a Middleware but the middleware doesn't apply to my IngressRoute. Both are well created but the middleware is not attached to my IngressRoute. I have no error logs even with the DEBUG log level. Something strange, I also have no errors if I reference a non existing middleware.

Did I missed something?

What did you do?

I have the following resources:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: fixed-header
  namespace: production
spec:
  headers:
    customRequestHeaders:
      Host: "myhost.com"
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  annotations:
    name: blog
    namespace: production
  name: blog
  namespace: production
spec:
  entryPoints:
  - websecure
  routes:
  - kind: Rule
    match: Host(`myhost.com`) && PathPrefix(`/blog`)
    services:
    - port: 80
      name: blog
  middlewares:
    - name: production-fixed-header@kubernetescrd

Also tried with:

  middlewares:
  - name: fixed-header
    namespace: production

And also:

  middlewares:
  - name: non-existing
    namespace: production

In the tree cases, Traefik logged no erros.

What version of Traefik are you using?

2.5.1

Describe the resource

> $ kubectl -n production describe ingressroutes.traefik.containo.us                                                                                                                                                                                                          
Name:         blog
Namespace:    production
Labels:       <none>
Annotations:  name: blog
              namespace: production
API Version:  traefik.containo.us/v1alpha1
Kind:         IngressRoute
Metadata:
  Creation Timestamp:  2022-12-19T21:23:51Z
  Generation:          1
  Managed Fields:
    API Version:  traefik.containo.us/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
          f:name:
          f:namespace:
      f:spec:
        .:
        f:entryPoints:
        f:middlewares:
        f:routes:
        f:tls:
          .:
          f:secretName:
    Manager:         kubectl-client-side-apply
    Operation:       Update
    Time:            2022-12-19T21:23:51Z
  Resource Version:  421033625
Spec:
  Entry Points:
    websecure
  Middlewares:
    Name:  fixed-header
  Routes:
    Kind:   Rule
    Match:  Host(`myhost.com`) && PathPrefix(`/blog`)
    Services:
      Name:  blog
      Port:  80
Events:           <none>
> $ kubectl -n production describe middlewares.traefik.containo.us                                                                                                                                                                                                            
Name:         fixed-header
Namespace:    production
Labels:       <none>
Annotations:  <none>
API Version:  traefik.containo.us/v1alpha1
Kind:         Middleware
Metadata:
  Creation Timestamp:  2022-12-19T21:23:51Z
  Generation:          1
  Managed Fields:
    API Version:  traefik.containo.us/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
      f:spec:
        .:
        f:headers:
          .:
          f:customRequestHeaders:
            .:
            f:Host:
            f:X-Script-Name:
          f:customResponseHeaders:
            .:
            f:X-Custom-Response-Header:
    Manager:         kubectl-client-side-apply
    Operation:       Update
    Time:            2022-12-19T21:23:51Z
  Resource Version:  421033624
Spec:
  Headers:
    Custom Request Headers:
      Host:               myhost.com
Events:                                <none>

I recommend to upgrade Traefik from 2.5.1 to 2.9.6 first.

Even with the latest version, I still have "There are no Middleware configured" on my route :slightly_frowning_face:

In addition, the Middleware is well added on the Ingress objects.

edit: I'm wondering, if this was an RBAC issue, would I have any errors?

This is a long time after, but hopefully helps others who arrive here.

This matches the behavour I am seeing. IngressRoutes don't allow updates (at least of middlewares and service ports, but possibly much more). Once I delete the existing IngressRoute everything works properly.

No error messages, nothing.