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: https://containo.us/blog/traefik-2-2-ingress/

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 'networking.k8s.io/v1beta1' 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
apiVersion: networking.k8s.io/v1beta1
metadata:
  name: myingress
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: web, websecure
    traefik.ingress.kubernetes.io/router.middlewares: redirect-http@kuberntes-crd

spec:
  rules:
  - host: mydomain.foo.com
    http:
      paths:
      - path: /bar
        backend:
          serviceName: whoami
          servicePort: 80

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

I tried already to define the middleware with:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: redirect-http
spec:
  redirectScheme:
    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.

Hello,

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:

    traefik.ingress.kubernetes.io/router.middlewares: 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) - #8 by sw360cab - Traefik v2 (latest) - Traefik Labs Community Forum