不同于 Istio,Traefik需要每个dep对应各自的 service
这里我们分别创建3个不同的 service 使用clusterip
创建 traefik service
apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
name: lizhets
namespace: version
spec:
weighted:
services:
- name: ver1
weight: 3 # 定义权重
port: 80
kind: Service # 可选,默认就是 Service
- name: ver2
weight: 1
port: 80
创建 IngressRoute
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: lizheingressroute
namespace: version
spec:
entryPoints:
- web
routes:
- match: Host(`ts.lizhe.com`)
kind: Rule
services:
- name: lizhets
kind: TraefikService
for i in `seq 20`; do curl http://ts.lizhe.com:8000/helloworld.html;echo "" ;done