Error with Middleware and Plugin Demo Configuration: "invalid middleware type or middleware does not exist"

Hi Traefik community,

I'm currently facing an issue with configuring a middleware that utilizes the Plugin Demo in Traefik using Kubernetes CRD (Custom Resource Definition). I have followed the documentation and created the necessary middleware, but I keep encountering the following error message:

invalid middleware 'default-plugindemo@kubernetescrd' configuration: invalid middleware type or middleware does not exist

Here's a screenshot capturing the error displayed on the Traefik dashboard.

Here's the full YAML configuration file for kubernetes containing:

  • Traefik Helm chart configuration
  • whoami application deployment and service
  • Middleware configuration
  • IngressRoute configuration

apiVersion: apps/v1
kind: Deployment
metadata:
  name: whoami
  labels:
    app: whoami
spec:
  selector:
    matchLabels:
      app: whoami
  template:
    metadata:
      labels:
        app: whoami
    spec:
      containers:
      - name: whoami
        image: traefik/whoami

---
apiVersion: v1
kind: Service
metadata:
  name: whoami-svc
spec:
  selector:
    app: whoami
  ports:
    - name: http
      protocol: TCP
      port: 80
  type: ClusterIP

---
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-
    additionalArguments:
      - "--api.dashboard=true"
      - "--log.level=DEBUG"
      - "--experimental.plugins.plugindemo.moduleName=github.com/traefik/plugindemo"
      - "--experimental.plugins.plugindemo.version=v0.2.2"
    ports:
      traefik:
        expose: true
    providers:
      kubernetesCRD:
        allowCrossNamespace: true
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: plugindemo
spec:
  plugin:
    plugindemo:
      Headers:
        X-Demo: test
        X-URL: '{{URL}}'

---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-whoami
spec:
  entryPoints:
  - web
  routes:
  - kind: Rule
    match: PathPrefix("/whoami")
    services:
    - name: whoami-svc
      port: 80
    middlewares:
      - name: plugindemo

Providing some additional context, I'm using Traefik v2.9.4 on a K3S cluster.
I have also tried using built-in middleware, like StripPrefix, and it worked just fine.

Can you please help me understand why I am encountering this error? Is there something incorrect with my middleware or CRD configuration? Any suggestions or insights would be greatly appreciated.

i have the same issue,
does any one have a solution for this ??

Hi, I had the same issue and came across this post. I made it work by setting the following helm chart values:

    experimental:
      plugins:
        enabled: true

Refer https://github.com/traefik/traefik-helm-chart/blob/v24.0.0/traefik/values.yaml#L124 .