envoy动态配置

2023-02-24  本文已影响0人  程序员札记

动态资源,是指由envoy通过xDS协议发现所需要的各项配置的机制,相关的配置信息保存 于称之为管理服务器(Management Server )的主机上,经由xDS API向外暴露;下面是一个 纯动态资源的基础配置框架。

{
"lds_config": "{...}",
"cds_config": "{...}",
"ads_config": "{...}"
}

xDS API为Envoy提供了资源的动态配置机制,它也被称为Data Plane API。
Envoy支持三种类型的配置信息的动态发现机制,相关的发现服务及其相应的API联合起来 称为xDS API。

v3 xDS支持如下几种资源类型

二、DS API介绍

Envoy对xDS API的管理由后端服务器实现,包括LDS、CDS、RDS、SRDS(Scoped Route)、VHDS (Virtual Host)、EDS、SDS、RTDS(Runtime )等。

xDS的各API还支持增量传输机制,包括ADS


image.png

三、Bootstrap node

一个Management Server 实例可能需要同时响应多个不同的Envoy实例的资源发现请求。

  1. Management Server上的配置需要为适配到不同的Envoy实例
  2. Envoy 实例请求发现配置时,需要在请求报文中上报自身的信息

专用的顶级配置段“node{…}”中配置

node: id: … # An opaque node identifier for the Envoy node. 
  cluster: … # Defines the local service cluster name where Envoy is running.
  metadata: {…} # Opaque metadata extending the node identifier. Envoy will pass this directly to the management server .
  locality: # Locality specifying where the Envoy instance is running.
    region: …
    zone: …
    sub_zone: …
  user_agent_name: … # Free-form string that identifies the entity requesting config. E.g . “envoy ” or “grpc”
  user_agent_version: … # Free-form string that identifies the version of the entity requesting config. E.g . “1.12.2” or “abcd1234” , or “SpecialEnvoyBuild ” 
  user_agent_build_version: # Structured version of the entity requesting config.
    version: …
    metadata: {…}
  extensions: [ ] # List of extensions and their versions supported by the node.
  client_features: [ ]
  listening_addresses: [ ] # Known listening ports on the node as a generic hint to the management server for filtering listeners to be returned

四、API的流程

1、对于典型的HTTP路由方案,xDS API的Management Server 需要为其客户端(Envoy实例)配 置的核心资源类型为Listener、RouteConfiguration、Cluster和ClusterLoadAssignment四个。每个Listener资源可以指向一个RouteConfiguration资源,该资源可以指向一个或多个Cluster资源,并且每个Cluster资源可以指向一个ClusterLoadAssignment资源。

2、Envoy实例在启动时请求加载所有Listener和Cluster资源,而后,再获取由这些Listener和 Cluster所依赖的RouteConfiguration和ClusterLoadAssignment配置;此种场景中,Listener资源和Cluster资源分别代表着客户端配置树上的“根(root)”配置,因而 可并行加载。

3、类型gRPC一类的非代理式客户端可以仅在启动时请求加载其感兴趣的Listener资源, 而后再加载这些特定Listener相关的RouteConfiguration资源;再然后,是这些 RouteConfiguration资源指向的Cluster资源,以及由这些Cluster资源依赖的 ClusterLoadAssignment资源;该种场景中,Listener资源是客户端整个配置树的“根”。

五、Envoy的配置方式

Envoy的架构支持非常灵活的配置方式:简单部署场景可以使用纯静态配置,而更复 杂的部署场景则可以逐步添加需要的动态配置机制

六、Envoy资源的配置源(ConfigSource)

1、配置源(ConfigSource)用于指定资源配置数据的来源,用于为Listener、Cluster、Route、 Endpoint、Secret和VirtualHost等资源提供配置数据。
2、目前,Envoy支持的资源配置源只能是path、api_config_source或ads其中之一。
3、api_config_source或ads的数据来自于xDS API Server,即Management Server。


image.png
上一篇 下一篇

猜你喜欢

热点阅读