設定:靜態

若要以靜態設定啟動 Envoy,您需要指定 listenersclusters 作為 static_resources

如果您希望監控 Envoy 或檢索統計資料,也可以新增 admin 區段。

以下章節將逐步說明 demo 設定 中提供的靜態設定,該設定檔在 Envoy Docker 容器中用作預設值。

static_resources

static_resources 包含 Envoy 啟動時靜態設定的所有內容,而不是在執行時動態設定。

1static_resources:
2
3  listeners:

listeners

此範例在連接埠 10000 上設定一個 listener

所有路徑都會比對並路由到 service_envoyproxy_io cluster

 1static_resources:
 2
 3  listeners:
 4  - name: listener_0
 5    address:
 6      socket_address:
 7        address: 0.0.0.0
 8        port_value: 10000
 9    filter_chains:
10    - filters:
11      - name: envoy.filters.network.http_connection_manager
12        typed_config:
13          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
14          stat_prefix: ingress_http
15          access_log:
16          - name: envoy.access_loggers.stdout
17            typed_config:
18              "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
19          http_filters:
20          - name: envoy.filters.http.router
21            typed_config:
22              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
23          route_config:
24            name: local_route
25            virtual_hosts:
26            - name: local_service
27              domains: ["*"]
28              routes:
29              - match:
30                  prefix: "/"
31                route:
32                  host_rewrite_literal: www.envoyproxy.io
33                  cluster: service_envoyproxy_io
34
35  clusters:
36  - name: service_envoyproxy_io

clusters

service_envoyproxy_io cluster 通過 TLS 代理到 https://envoy.dev.org.tw

31                route:
32                  host_rewrite_literal: www.envoyproxy.io
33                  cluster: service_envoyproxy_io
34
35  clusters:
36  - name: service_envoyproxy_io
37    type: LOGICAL_DNS
38    # Comment out the following line to test on v6 networks
39    dns_lookup_family: V4_ONLY
40    load_assignment:
41      cluster_name: service_envoyproxy_io
42      endpoints:
43      - lb_endpoints:
44        - endpoint:
45            address:
46              socket_address:
47                address: www.envoyproxy.io
48                port_value: 443
49    transport_socket:
50      name: envoy.transport_sockets.tls
51      typed_config:
52        "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
53        sni: www.envoyproxy.io