简体   繁体   中英

traefik ingress wildcard support

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

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

path: /api/{version:v1([az]*)}/customers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM