Global middleware with kubernetes CRD

Hello,

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

traefik.http.middlewares.test-auth.forwardauth.address=https://example.com/auth

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

Cheers,

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.

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

<middleware-namespace>-<middleware-name>@kubernetescrd

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

You can learn more about it by reading Traefik's docs:
https://doc.traefik.io/traefik/providers/overview/#provider-namespace

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