2 minutes Envoy grasp of context, to adapt to the new scene envoy What are the differences? What can we do?

本篇 directory

Explanation

When combing open source API Gateway and ServiceMesh project, a word most frequently encountered are the data plane Envoy, Ambassador, Contour, Gloo, Istio other projects are selected Envoy. Envoy Hedeheneng favored by many project? Envoy to grasp the context of just 2 minutes.

He responded to the call of the times Envoy

Envoy is having a reverse proxy and load balancing stand-alone software, and Nginx, Haproxy belong to the same category of software. Compared with Nginx and Haproxy, Envoy there is one important feature: built-configuration API.

With Nginx, Haproxy represented by load-balancing software, in practical applications for many years in the past, rarely change the configuration when the software is running, even if occasionally you want to modify the configuration file, use the reload command to reload, etc. will be able to meet their needs.

Directions evolve to Kubernetes as the representative of PaaS or container management system after emergence, IT systems along the "division of labor specialization, fewer people to do more homogeneous things" in the current evolution, reverse proxy and load balancing the ability to be centrally managed, unified offer.

This evolution is reflected in Kubernetes for all services within the cluster as exports ingress proxy cluster, embodied agent software flung circulation flow under the control of a single center in order to istio represented in ServiceMesh. Either as export Kubernetes, or as a node in the Mesh, bear traffic forwarding components are required to complete a challenge: frequent updating configuration during operation.

The frequency of updates new scene is N times per second, far exceeding the previous update frequency of the scene in weeks, months or even years for the cycle. In this case, the thermal load profile significantly slow cumbersome way, there are a number of projects with a development component through the API functions to achieve generates configuration files, triggers the function of the heat load, this gives Nginx, Haproxy other traditional load balancing software HF ability to update configurations.

However, if there is a software configuration with native API, and focus on the data plane, it exists as a reliable third party, allowing control plane management to concentrate on the rules, then it would not be very popular?

Envoy is such a software. Note that this only explain the background, not to blow envoy ticket, nginx, haproxy so updating evolve to adapt to changes in the scene.

Cluster、Listener 与 Filter

Envoy features and details of the use of complicated, but as long to figure out the use of Cluster, Listener and Filter, we grasp the general direction.

Cluster is a group of IP, the equivalent of Nginx in upstream, load balancing strategy in the cluster set, cluster can be IP can also be a domain name:

envoy的cluster

Listener is listening address and forwarding rules:

envoy的listener

Hard nut to profile

Envoy configuration file is the greatest difficulty encountered scratch understand Envoy, its configuration is complicated, and the lack of system introduction.

Configuration file when you start envoy, with  -c specified content into the following sections:

{
  "node": { "id": "...", "cluster": "...", "metadata": "{...}", "locality": "{...}", "build_version": "..." }, "static_resources": { "listeners": [], "clusters": [], "secrets": [] }, "dynamic_resources": { "lds_config": "{...}", "cds_config": "{...}", "ads_config": "{...}" }, "cluster_manager": { "local_cluster_name": "...", "outlier_detection": "{...}", "upstream_bind_config": "{...}", "load_stats_config": "{...}" }, "hds_config": { "api_type": "...", "cluster_names": [], "grpc_services": [], "refresh_delay": "{...}", "request_timeout": "{...}", "rate_limit_settings": "{...}" }, "flags_path": "...", "stats_sinks": [ { "name": "...", "config": "{...}" } ], "stats_config": { "stats_tags": [], "use_all_default_tags": "{...}", "stats_matcher": "{...}" }, "stats_flush_interval": "{...}", "watchdog": { "miss_timeout": "{...}", "megamiss_timeout": "{...}", "kill_timeout": "{...}", "multikill_timeout": "{...}" }, "tracing": { "http": "{...}" }, "rate_limit_service": { "grpc_service": "{...}" }, "runtime": { "symlink_root": "...", "subdirectory": "...", "override_subdirectory": "..." }, "admin": { "access_log_path": "...", "profile_path": "...", "address": "{...}" }, "overload_manager": { "refresh_interval": "{...}", "resource_monitors": [], "actions": [] } }

View envoy container in the default configuration file, help build perceptions, as follows:

admin:
  access_log_path: /tmp/admin_access.log address: socket_address: protocol: TCP address: 127.0.0.1 port_value: 9901 static_resources: listeners: - name: listener_0 address: socket_address: protocol: TCP address: 0.0.0.0 port_value: 10000 filter_chains: - filters: - name: envoy.http_connection_manager typed_config: "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager stat_prefix: ingress_http route_config: name: local_route virtual_hosts: - name: local_service domains: ["*"] routes: - match: prefix: "/" route: host_rewrite: www.google.com cluster: service_google http_filters: - name: envoy.router clusters: - name: service_google connect_timeout: 0.25s type: LOGICAL_DNS # Comment out the following line to test on v6 networks dns_lookup_family: V4_ONLY lb_policy: ROUND_ROBIN load_assignment: cluster_name: service_google endpoints: - lb_endpoints: - endpoint: address: socket_address: address: www.google.com port_value: 443 tls_context: sni: www.google.com 

Envoy to master configuration file, is a critical step grasp of the software, how to master the envoy of configuration? Put it all configuration details remember of course be mastered, but most of the time we do not need this, just need to know the real-time reaction profile in where full details of the document is enough, the rest to time and curiosity:

Detailed profiles envoy

Play the leading role of the filter

几乎可以这样说,在实际应用中最常提及的 envoy 功能都是 filter 提供的, filter 是流量在 envoy 内流转时经历的一个又一个处理环节,每个环节都会解读一些信息、作出一些判断,影响下一个环节的处理。

Cluster 和 Listener 中都有 filter 的位置,有的 filter 比较复杂还实现了 子 filter,例如专门处理 http 协议的 HttpConnectionManager。 Filter 的数量实在太多,知道到哪里找到所有 filter 的说明和配置方法比记住个别 filter 的用法更重要:

envoy listener filter

envoy network filter

这些 filter 的名称很好的展示了 envoy 能够做的事情,http、thrift、dubbo、zookeeper、mysql、mongo、redis,看起来是不是挺诱人的?

动态配置到底怎么回事?

envoy 的一大卖点就是自带配置 API,但要把它自带的 API 用起来还挺周折。envoy 率先提出使用统一的 data-plane-api ,定义了一套 API 标准,并期待能够得到广泛的认同和采纳,从新起的 Api 网关和 ServiceMesh 开源项目的选择来看,这一策略是有效的。

date-plane-api

go-controller-plane 是 envoy 提出的 data-plane-api 的 go 语言实现,可以用它向 envoy 下发配置,这个库的使用方法三言两语说不清楚,先弄清楚下面三个项目的关系: envoy 就是单机软件 envoy,data-plane-api 是 API 接口标准,go-control-plane 是 API 接口标准的实现。

envoy network filter

动手实践一下

API comes configured to support dynamic updates, Cluster, Listener, Filter constitute the skeleton Envoy's function, if after reading the above description, the feeling is still hazy as smoke and mirrors, want to see more clearly, do not knock again cf.  Envoy manual  operation quicker way of:

Click to view:  Envoy manual

envoy Manual

reference

  1. Lee Ji Australia's blog
  2. Envoy Manual

Guess you like

Origin www.cnblogs.com/lijiaocn/p/11488506.html