Is it possible to set the default frontend rule type?

9/2/2019

https://docs.traefik.io/configuration/backends/kubernetes/#general-annotations Says that the traefik.ingress.kubernetes.io/rule-type annotation overrides the the default frontend rule type.

Is there any way to set the default frontend rule type to PathPrefixStrip so I will not have to override it in every single Ingress definition?

-- majkrzak
kubernetes
kubernetes-ingress
traefik
traefik-ingress

2 Answers

9/4/2019

As far as I know, you can use Traefik Static configuration file and explicitly propagate global configuration for entrypoints, frontends and backends objects.

Static config applies Traefik settings at the traefik-ingress-controller initialization phase, thus all dynamically created sources, like K8s Ingress resources may override some key-value parameters as per precedence order behavior.

Therefore, you might consider including Matcher route rules via PathPrefixStrip parameter for the target Frontends within a global configuration file, i.e:

[frontends]
  [frontends.frontend1]
  backend = "backend1"
    [frontends.frontend1.routes.test_1]
    rule = "PathPrefixStrip:/somepath"

More details about Traefik TOML file template and design you can find here.

-- mk_sta
Source: StackOverflow

10/8/2019

No, in traefik 1.7 default fronted rule is hardcoded and not documented. https://github.com/containous/traefik/blob/v1.7/provider/kubernetes/kubernetes.go#L48

    defaultFrontendRule        = "PathPrefix:/"
//...

                if len(frontend.Routes) == 0 {
                    frontend.Routes["/"] = types.Route{
                        Rule: defaultFrontendRule,
                    }
                }
//...
    templateObjects.Frontends[defaultFrontendName].Routes["/"] = types.Route{
        Rule: defaultFrontendRule,
    }
-- majkrzak
Source: StackOverflow