从集群内部使用Istio VirtualService



我不能使用Kubernetes服务,因为我需要retryVirtualService功能。如何从pod访问VirtualService?

如果我通过网关使用VirtualService:Pod->Kubernetes service->Istio Gateway->Virtual service则由于某种原因CCD_ 6平衡特性不起作用。

我猜你有这样的东西:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: review-external
spec:
hosts:
- "*.example.com"
gateways:
- mygateway
http:
route:
- destination:
host: reviews.prod.svc.cluster.local
subset: v2
weight: 25

在这种情况下,可以使用VirtualService对象中的gateways列表。

对于文档:

如果省略此字段,将使用默认网关(网格(,它将把规则应用于网格中的所有sidecar。如果提供了网关名称列表,则规则将仅适用于网关。要将规则应用于网关和sidecar,请将mesh指定为网关名称之一。

来源:https://istio.io/latest/zh/docs/reference/config/networking/virtual-service/#VirtualService

所以你有两个选择。您可以将mesh作为网关之一:

[...]
gateways:
- mygateway
- mesh
http:
[...]

或者,您可以创建第二个没有gateways列表的VirtualService,使其默认为mesh(或者,如果您希望声明性,则仅提及网格作为网关(。spec.hosts字段必须包含destination.host中提到的主机。

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: review-mesh-internal
spec:
hosts:
- "reviews.prod.svc.cluster.local" # must be the kubernetes service host as below
gateways:
- mesh #optional since it's the default
http:
route:
- destination:
host: reviews.prod.svc.cluster.local
subset: v1
weight: 100

这带来的优点是,您可以以不同于集群内部的方式路由集群外部的流量。例如,考虑维护,其中用户流量不应该到达特定的pod,但来自集群内部的流量应该仍然能够到达

最新更新