我正在为一组内部服务实现一些路由逻辑,其中委托VirtualService看起来是一个很好的解决方案:
https://istio.io/latest/docs/reference/config/networking/virtual-service/#Delegate
我创建了一些测试设置,类似于文档中的设置,但只有一个区别。在我的例子中,“根”主机绑定到“网格”网关,而“VirtualService”则是某个内部服务名称。这是否应该起作用,或者委派只对非网状网关起作用?
这是根VirtualService (其思想是将所有请求发送到worker-pool.default.svc.cluster.local,然后根据某些HTTP头将它们转发到其他VirtualServices):
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发布于 2021-04-16 16:32:18
我想有几点需要考虑:
据我所知,
spec:
gateways:
- mesh
hosts:
- worker-pool.default.svc.cluster.local
http:
... delegate:
name: worker-for-bob
namespace: <some-namespace>上可能需要将变量PILOT_ENABLE_VIRTUAL_SERVICE_DELEGATE设置为“”
kubectl edit deployment istiod -n istio-system然后在spec.template.spec.container.env中添加这个环境变量
https://stackoverflow.com/questions/65795057
复制相似问题