組態:從控制平面動態配置
這些說明稍微複雜一些,因為您還必須設定一個控制平面,以向 Envoy 提供其組態。
有許多與 Envoy 的 API 相容的控制平面,例如 Gloo 或 Istio。
您可能也希望探索實作自己的控制平面,在這種情況下,Go Control Plane 提供了一個參考實作,這是一個很好的起點。
您至少需要啟動已配置以下區段的 Envoy
node 以唯一識別代理節點。
dynamic_resources 以告知 Envoy 哪些組態應動態更新
static_resources 以指定 Envoy 應從何處擷取其組態。
如果您希望監控 Envoy 或擷取統計資料或組態資訊,您還可以新增一個 admin 區段。
以下各節將逐步說明 demo dynamic control plane configuration file
中提供的動態組態。
node
node 應指定 cluster
和 id
。
1node:
2 cluster: test-cluster
3 id: test-id
4
5dynamic_resources:
dynamic_resources
dynamic_resources 指定要動態載入的組態,以及要連線以進行動態組態更新的 cluster。
在此範例中,組態由下方配置的 xds_cluster
提供。
3 id: test-id
4
5dynamic_resources:
6 ads_config:
7 api_type: GRPC
8 grpc_services:
9 - envoy_grpc:
10 cluster_name: xds_cluster
11 cds_config:
12 ads: {}
13 lds_config:
14 ads: {}
15
16static_resources:
17 clusters:
18 - type: STRICT_DNS
19 typed_extension_protocol_options:
static_resources
在這裡,我們指定 static_resources 以從中擷取動態組態。
xds_cluster
配置為在 http://my-control-plane:18000 查詢控制平面。
17 clusters:
18 - type: STRICT_DNS
19 typed_extension_protocol_options:
20 envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
21 "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
22 explicit_http_config:
23 http2_protocol_options: {}
24 name: xds_cluster
25 load_assignment:
26 cluster_name: xds_cluster
27 endpoints:
28 - lb_endpoints:
29 - endpoint:
30 address:
31 socket_address:
32 address: my-control-plane
33 port_value: 18000
34
35admin:
36 address:
37 socket_address:
38 address: 0.0.0.0