Kubernetes traefik middleware


I have created a helm chart with a set of traefik middleware and deployed it to the namespaces where traefik 2.0 is deployed.

I have now deployed a ingressroute in a different namespaces. How can i reference the middleware from a different namespace?

Should each kubernetes namespace have the middleware?

  • Traefik deployed to default namespace

  • Helm chart with Traefik Middle ware deployed alongside with Traefik into the default namespace

  • IngressRoute deployed to dev namespace

  • In order to access the middle ware from the default namespace I had to do the following default-chain-api-gateway@kubernetescrd

I don't find it very flexible. If i were to deploy Traefik to a different namespace things would be broken I assume.

What is the best way to have a set of middleware across different namespaces.

I have one cluster where I have three different environments, dev, qa, staging as namespaces

Hi @ekjuanrejon, can you share more informations with us please? It's partial and doesn't give us material to help you.

Not sure to understand the problem though: an ingress route is able to reference a middleware from another namespace, as explained in the documentation: https://docs.traefik.io/v2.0/routing/providers/kubernetes-crd/#middleware

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
  name: ingressroutebar
    - web
  - match: Host(`bar.com`) && PathPrefix(`/stripit`)
    kind: Rule
    - name: whoami
      port: 80
    - name: stripprefix
      namespace: foo

=> This Ingressroute is on the default namespace, and references a middleware in the namespace foo.

1 Like