Traefikv2 middleware error - not found

I am having problems configuring ip whitelisting with traefik 2 on Google Kubernetes Engine

This is the middleware yaml

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: ipwhitelist
  namespace: traefik
spec:
  ipWhiteList:
    sourceRange:
      - 199.83.128.0/21

And this is my ingress controller

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: websecure
    traefik.ingress.kubernetes.io/router.tls: "true"
    ingress.kubernetes.io/service-upstream: "true"
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/router.middlewares: traefik-ipwhitelist@kubernetescrd
  name: front-cms
spec:
  rules:
    - host: xxx.aaa.es
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: front-cms
                port:
                  number: 80

When I try to load the webpage I get a 404 (without the traefik.ingress.kubernetes.io/router.middlewares: traefik-ipwhitelist@kubernetescrdline it works just fine).

On traefik service logs I get the following error

time="2022-11-07T09:53:12Z" level=error msg="middleware \"traefik-ipwhitelist@kubernetescrd\" does not exist" entryPointName=websecure routerName=es-prod-front-cms-xxx-cms-aaa-es@kubernetes
  • Traefik resource and service are on kube-system namespace.
  • Middleware is on traefik namespace
  • web ingress controller is on es-prod namespace

Could anybody help me?

I recommend to add Kubernetes tag to your post.

1 Like