我编写了一个虚拟服务来测试基于标头的路由
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: http-app
namespace: default
spec:
hosts:
- http-app.default.svc.cluster.local
http:
- match:
- headers:
canary-token:
exact: haha
route:
- destination:
host: http-app.default.svc.cluster.local
subset: canary
- route:
- destination:
host: http-app.default.svc.cluster.local
subset: stable
Run Code Online (Sandbox Code Playgroud)
服务正常时流量路由正确
apiVersion: v1
kind: Service
metadata:
name: http-app
namespace: default
labels:
env: prod
spec:
type: ClusterIP
selector:
app: http-app
ports:
- port: 3011
targetPort: 3011
Run Code Online (Sandbox Code Playgroud)
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: http-app
namespace: default
spec:
hosts:
- http-app.default.svc.cluster.local
http:
- match:
- headers: …Run Code Online (Sandbox Code Playgroud)