Global middleware with kubernetes CRD


In traefik v2 with docker provider we can register a "global" middleware as:


However when using kubernetes crd as provider, how do we register a "global" middleware for traefik?


Hello @nwrox

All objects that are created within the Kubernetes cluster are grouped by namespace - according to the documentation you can think of a Namespace as a virtual cluster.

One of the aims of a namespace is a logical isolation of objects from each other. A standard Kubernetes cluster is shipped with kube-system (Kubernetes components), kube-public (for public resources), and default for user's workloads.

Referring that knowledge to the Traefik implementation through IngressRoute CRD (Custom Resource Definition) we have to create a middleware in a specific namespace e.g.

kind: Middleware
  name: http2https
  namespace: default
    scheme: https
    permanent: true

If you create a middleware as CRD in Kubernetes as it is presented in the example you should refer to it using the following annotation:


so you should use the name: default-http2https@kubernetescrd

You can learn more about it by reading Traefik's docs:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.