istio 中的 VirtualService 和 Gateway 有什么区别?

What is the difference VirtualService and Gateway in istio?

我想了解 istio 中 VirtualService 和 Gateway 之间的区别?据我所知,VirutalService 也用于路由与 Gateway

相同的流量

根据 istio 文档:

A VirtualService defines a set of traffic routing rules to apply when a host is addressed. Each routing rule defines matching criteria for traffic of a specific protocol. If the traffic is matched, then it is sent to a named destination service (or subset/version of it) defined in the registry.

Gateway describes a load balancer operating at the edge of the mesh receiving incoming or outgoing HTTP/TCP connections. The specification describes a set of ports that should be exposed, the type of protocol to use, SNI configuration for the load balancer, etc.

Gateway一般用来对外暴露一个VirtualService。因此,使用此对象,我们可以控制来自外部的流量如何以及哪些流量将到达我们的 VirtualServices 之一。也可以指定 Gateway 如何处理流量,例如TLS termination or SNI passthrough.

有些配置只有在 GatewayVirtualService 一起工作时才有可能。

简而言之,Gateway 用于外部流量,而 VirtualService 用于已经在 istio 集群内部的流量。