【发布时间】:2021-04-23 23:06:39
【问题描述】:
我正在为一组内部服务实现一些路由逻辑,其中委托 VirtualService 看起来是一个很好的解决方案:
https://istio.io/latest/docs/reference/config/networking/virtual-service/#Delegate
我创建了一些类似于文档中的测试设置,只有一个区别。就我而言,绑定到“网格”网关的“根”虚拟服务和“主机”是一些内部服务名称。这应该有效还是委托仅适用于非网状网关?
这是根 VirtualService(想法是所有请求都发送到worker-pool.default.svc.cluster.local,然后根据一些 HTTP 标头将它们转发到其他 VirtualService):
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: worker-pool
spec:
hosts:
- worker-pool.default.svc.cluster.local
http:
- name: "route 1"
match:
- headers:
customer-id:
exact: alice
delegate:
name: worker-for-alice
- name: "route 2"
match:
- headers:
customer-id:
exact: bob
delegate:
name: worker-for-bob
这里还有另一个 VirtualService(只显示一个,两者看起来一样):
apiVersion: v1
kind: Service
metadata:
name: worker-for-alice
labels:
app: worker-for-alice
service: worker-for-alice
spec:
...
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: worker-for-alice
spec:
http:
- route:
- destination:
host: worker-for-alice
【问题讨论】:
-
嘿@F7502,是的,代理应该使用网状网关。
curl -v worker-pool/的输出是什么?您能否尝试将delegate更改为route,以便使用单个虚拟服务并检查它是否有效?从我的角度来看,delegate 可能不适用于标头,因为它适用于 uri,您可以阅读有关它的更多信息here。
标签: istio