这不是我想要解决这个问题的方式。基本上我控制了一个 pod 的传入流量,但我想控制一个 pod 的出站流量。但是,我在这里发布了我的 hacky 解决方案。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: handle-internal-traffic
namespace: demo
spec:
hosts:
- "service-1"
gateways:
- mesh
http:
- match:
- sourceLabels:
version: v1
uri:
exact: /
route:
- destination:
host: service-1
subset: v1
- match:
- uri:
exact: /api
rewrite:
uri: "/"
route:
- destination:
host: service-1
subset: v2
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: service-1
namespace: demo
spec:
host: service-1.demo.svc.cluster.local
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
当请求来自网状网络的其他 pod 时,只需过滤标签。