Istio从入门到精通—— 流量治理的原理 —— VirutalService —— TLSRoute

流量治理的原理 —— VirutalService —— TLSRoute

https://istio.io/latest/docs/reference/config/networking/virtual-service/#TLSRoute

Describes match conditions and actions for routing unterminated TLS traffic (TLS/HTTPS) The following routing rule forwards unterminated TLS traffic arriving at port 443 of gateway called “mygateway” to internal services in the mesh based on the SNI value.

描述了匹配条件和操作以路由未终止的 TLS 流量(TLS/HTTPS)。以下路由规则将基于 SNI 值将到达名为 "mygateway" 网关端口 443 的未终止的 TLS 流量转发到网格中的内部服务。

我的理解是:"The following routing rule forwards unterminated TLS traffic arriving at port 443 of gateway called “mygateway” to internal services in the mesh based on the SNI value.":这是主要的路由规则描述。这里的 "unterminated TLS traffic" 指的是到达 443 端口的未终止的 TLS 或 HTTPS 流量。"mygateway" 则是指一个名为 "mygateway" 的网关。根据 SNI(服务器名称指示)的值,这个路由规则将把到达这个网关的未终止的 TLS 流量转发到服务网格中的内部服务。

我的理解是:"Describes match conditions and actions for routing unterminated TLS traffic (TLS/HTTPS)":这句话主要描述了如何匹配和路由未终止的 TLS (传输层安全性)或 HTTPS (安全超文本传输协议)流量。

apiVersion: networking.istio.io/v1alpha3 //定义 Istio 的 VirtualSerivce API 的版本。
kind: VirtualService  //定义 kubernets 的资源种类为 VirtualService。
metadata:
  name: bookinfo-sni
spec:
  hosts:
  - "*.bookinfo.com"  //定义了 virutalservice 所处理的请求的主机名,这里是指以 bookinfo.com 为后缀的所有子域名。
  gateways:
  - mygateway         //定义了 virutalservice 所关联的网关,这个网关名称为 "mygateway"。
  tls:
  - match:
    - port: 443   //定义了当通过 443 端口进行连接,且 sniHosts 名为 login.bookinfo.com 时的匹配规则。
      sniHosts:
      - login.bookinfo.com
    route:
    - destination:
        host: login.prod.svc.cluster.local //当上述条件匹配时,请求将被路由到名为 login.prod.svc.cluster.local 的服务。
  - match:
    - port: 443
      sniHosts:
      - reviews.bookinfo.com  //定义了当通过 443 端口进行连接,且 sniHosts 名为 reviews.bookinfo.com 时的匹配规则。
    route:
    - destination:
        host: reviews.prod.svc.cluster.local //当上述条件匹配时,请求将被路由到名为 reviews.prod.svc.cluster.local 的服务。
      

我的理解是:定义了一个名为 "bookinfo-sni" 的 VirtualSerivce,该服务根据不同的主机名和端口,将请求路由到不同的目标服务。在这里,通过 sniHosts 和端口 443 的组合,将特定主机的请求路由到不同的服务。例如,当请求的主机名是 login.bookinfo.com,且通过 443 端口进行连接时,请求将被路由到 login.prod.svc.cluster.local 服务;同样地,当请求的主机名是 reviews.bookinfo.com,且通过 443 端口进行连接时,请求将被路由到 reviews.prod.svc.cluster.local 服务。

Field Type Description Required
match TLSMatchAttributes[] Match conditions to be satisfied for the rule to be activated. All conditions inside a single match block have AND semantics, while the list of match blocks have OR semantics. The rule is matched if any one of the match blocks succeed.

将条件匹配到规则激活所需满足的条件。单个匹配块中的所有条件都具有AND语义,而匹配块的列表具有OR语义。如果任何一个匹配块成功,则该规则将被匹配。

Yes
route RouteDestination[]

The destination to which the connection should be forwarded to.

该连接应该被重定向到的目标。

No
posted @ 2023-12-12 13:20  左扬  阅读(23)  评论(0编辑  收藏  举报
levels of contents