Traefik 流量复制

流量复制可以将 request 发给主 endpoint 的同时,将同样的request发给另一个endpoint,并且忽略第二个endpoint的response

apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
  name: app-mirror
  namespace: version
spec:
  mirroring:
    name: ver1 # 发送 100% 的请求到 K8S 的 Service "v1"
    port: 80
    mirrors:
    - name: ver2 # 然后复制 50% 的请求到 v2
      percent: 50
      port: 80

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: mirror-ingress-route
  namespace: version
spec:
  entryPoints:
  - web
  routes:   
  - match: Host(`mi.lizhe.com`)
    kind: Rule
    services:
    - name: app-mirror
      kind: TraefikService # 使用声明的 TraefikService 服务,而不是 K8S 的 Service
for i in `seq 20`; do curl http://mi.lizhe.com:8000/helloworld.html;echo "" ;done
Send a Message