V2.5.0 Can't reference middlewares in another namespaces from an ingressroute

What did you do?

I have the following ingress route:

kind: IngressRoute
apiVersion: traefik.containo.us/v1alpha1
metadata:
  name: auth-route-secure
  namespace: authentication
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`auth.domain.com`)
      kind: Rule
      services:
        - kind: Service
          name: auth-service
          port: 9091
      middlewares:
        - name: traefik-security@kubernetescrd

and the following middleware:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  namespace: traefik
  name: security
spec:

  headers:
    frameDeny: true               
    sslRedirect: true             
    browserXssFilter: true    
    contentTypeNosniff: true
    stsIncludeSubdomains: true
    stsPreload: true              
    stsSeconds: 31536000  

Up until traefik v2.5.0 everything was working perfectly...

What did you see instead?

level=error msg="Failed to create middleware keys: invalid reference to middleware traefik-security@kubernetescrd: with crossnamespace disallowed, the namespace field needs to be explicitly specified" providerName=kubernetescrd ingress=auth-route-secure namespace=authentication

What version of Traefik are you using?

v2.5.0

What is your environment & configuration?

persistence:
  enabled: true
  storageClass: "longhorn"
  size: 128Mi

Default helm chart with added changes defined above

The only way I see it working is if everything is in the same namespaces now... which is not acceptable

in the past (pre v2.5.0) if you would put the middleware as namespace-name@provider
traefik would find the middleware without problem (as stated in the doc)

if you would not do that and specify the name and the namespaces without the provider:
middlewares:

  • name: foo
    namespace: bar

It would resolve it all the same

BUT NOW

if you go for the first option you have: Failed to create middleware keys: invalid reference to middleware namespace-name@provider

and if you go for the second option you have: middleware bar/foo is not in the IngressRoute namespace

I have now reverted to v2.4.13 until v2.5.0 is fixed

Hello,

From the error message:

with crossnamespace disallowed, the namespace field needs to be explicitly specified

are you allowing cross namespace?

Indeed I have not ! The chart values doesn't mention any of this so I didn't see it !

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