traefik ingress wildcard support

6/25/2020

I am following traefik documentation (https://docs.traefik.io/routing/routers/), want to use PathPrefix matcher to match different paths with wildcard support, for example, to match path starting with api/v1, it should match

api/v1/customers,

api/v1alpha/customers,

api/v1beta/customers.

How to achieve it using wildcards in path syntax? Please find below my ingress yaml. I tried /api/{v1*}/customers but not working as expected.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.rule.type: PathPrefix
  labels:
    app: <app_name>
    chart: <chart_name>
    heritage: Tiller
    release: <release_name>
  name: <name>
  namespace: default
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: <service_name>
          servicePort: 443
        path: /api/v1*/customers
-- Abhay
kubernetes
kubernetes-ingress
nginx-ingress
traefik
traefik-ingress

1 Answer

7/2/2020

I figured out how it works, posting here if someone wants to know. We can add regular expression in path

path: /api/{version:v1(a-z*)}/customers

-- Abhay
Source: StackOverflow