配置:静态

要使用静态配置启动 Envoy,您需要指定 listenersclusters 作为 static_resources.

如果您希望监控 Envoy 或检索统计信息,您还可以添加 admin 部分。

以下部分介绍了在 Envoy Docker 容器中用作默认值的 demo configuration file 中提供的静态配置。

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.k8s.ac.cn

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