Traefik 2.2 - kubernetesingress - middleware "redirect-http@kuberntes-crd" does not exist

I am running traefik v2.2 in a self managed kubernetes cluster 1.17.3
I am trying the new kubernetesingress provider in Traefik 2.2. I followed the documentation page for v2.2 Latest here.

This works for HTTP fine. But if I try to configure a middleware for http/https redirection like announced in this blog post:

traefik complains that the ingress middleware can not be found. Log Messages:

2020-04-04T20:07:57.720776497Z time="2020-04-04T20:07:57Z" level=error msg="Cannot create service: subset not found" namespace=default serviceName=whoami servicePort=80 providerName=kubernetes ingress=myingress
2020-04-04T20:07:57.882206863Z time="2020-04-04T20:07:57Z" level=warning msg="Ingress default/myingress: the apiVersion 'extensions/v1beta1' is deprecated, use '' instead."
2020-04-04T20:07:57.882260265Z time="2020-04-04T20:07:57Z" level=error msg="middleware \"redirect-http@kubernetesingress\" does not exist" entryPointName=web routerName=myingress-default-mydomain-foo-com-bar@kubernetes
2020-04-04T20:07:57.882269368Ztime="2020-04-04T20:07:57Z" level=error msg="middleware \"redirect-http@kubernetesingress\" does not exist" entryPointName=websecure routerName=myingress

my ingress config looks like this:

kind: Ingress
  name: myingress
  annotations: web, websecure redirect-http@kuberntes-crd

  - host:
      - path: /bar
          serviceName: whoami
          servicePort: 80

If I only use the "web" entry point it works for http.

I tried already to define the middleware with:

kind: Middleware
  name: redirect-http
    scheme: https

But this did also not work. I am running kubernetes version 1.17. It is not clear to me if this feature should already work or if there is something missing.
Please let me know if I can provide any more useful information about this issue.

Thanks for any help.


inside a provider you don't need to set the provider namespace.

also the provider namespace for k8s CRD is @kuberntescrd

I think I solved my problem: The middleware name used in the ingress configuration must be prafixed with 'default-'. This is the name under which the middlewares are listed in traefik.

So the annoation is: default-redirect-http@kuberntescrd

Also it is important that both providers are activated in the traefik deployment:

      - args:
        - --api
        - --providers.kubernetescrd=true
        - --providers.kubernetesingress=true

Maybe this is something which can be added into the example of the documentation page.

I wrote this blog which maybe helpful for users running into the same problem.

1 Like

Just want to add additional info here

default- prefix is refers to what k8s namespace the middleware manifest is deployed to. If it is deployed in kubernetes default namespace, of course the prefix will be default-. But if you deploy middleware manifest into abcde namespace, the prefix will be abcde-

Just found about this info in How to configure middleware with kubernetes-ingress? (middleware "xyz" does not exist)