1什么service
service指的是envoy提供的grpc或http服务,大多数是grpc的。他的主要作用是与外部系统交互,发送数据,或接收配置。service是envoy一块很重要的内容,需要重点掌握。
2envoy有哪些service
accesslog service(als)
load reporting service(lrs)
Attribute Context
Authorization Service
Health Discovery Service (HDS)
Metrics service
Rate Limit Service (RLS)
Runtime Discovery Service (RTDS)
Client Status Discovery Service (CSDS)
Tap Sink Service
Trace service
Extension Config Discovery Service (ECDS)
External Processing Service
Aggregated Discovery Service (ADS)
Cluster discovery service (CDS)
gRPC Event Reporting Service
Listener discovery service (LDS)
Route discovery service (RDS)
Secret discovery service (SDS)
Virtual Host Discovery Service (VHDS)
Endpoint discovery service(eds)
3各service介绍
3.1accesslog service(als)
als是envoy提供一个grpc服务,主要作用是外部应用(比如skywalking)收集envoy proxy istio-proxy container产生的访问日志,收集完可用于分析,告警。
配置方法:
mesh: |-accessLogFile: /dev/stdoutenableEnvoyAccessLogService: truedefaultConfig:envoyAccessLogService:address: skywalking-oap.istio-system:11800discoveryAddress: istiod.istio-system.svc:15012proxyMetadata: {}tracing:zipkin:address: zipkin.istio-system:9411enablePrometheusMerge: truerootNamespace: istio-systemtrustDomain: cluster.localmeshNetworks: 'networks: {}'
3.2load reporting service(lrs)
lrs提供一种机制,envoy可以向管理服务器周期性报告load report。
配置方法:
cluster_manager:load_stats_config:api_type: GRPCtransport_api_version: V3grpc_services:- envoy_grpc:cluster_name: load_reporting_cluster
参考:
https://github.com/envoyproxy/envoy/tree/main/examples/load-reporting-service
3.3Attribute Context
attribute是一片描述活动的元数据,例如http请求的大小,http响应的状态码。每个attribute有一个类型和名字,他们是定义attribute context中的。attribute context 是独立attribute的集合用来支持enovy的外部授权系统。
3.4Authorization Service
Authorization Service指的是外部授权服务。外部服务可以是grpc服务和可以是http服务。外部授权服务提供了AuthorizationPolicy crd功能以外的外接式授权服务,比如和业务授权系统整合起来。
配置方法:
mesh: |-# Add the following contents:extensionProviders:- name: "opa.istio"envoyExtAuthzGrpc:service: "opa.istio.svc.cluster.local"port: "9191"
3.5Health Discovery Service (HDS)
健康发现服务
配置方法:
hds_config:api_type: GRPCtransport_api_version: v3set_node_on_first_message_only: truegrpc_services:envoy_grpc:cluster_name: xds-grpctimeout: 3s
3.6Metrics service
指标服务,用于监控
配置方法:
stats_sinks:- name: envoy.stat_sinks.metrics_servicetyped_config:"@type": type.googleapis.com/envoy.config.metrics.v3.MetricsServiceConfigtransport_api_version: V3grpc_service:envoy_grpc:cluster_name: metrics-server.istio.svc.cluster.localtimeout: 3sreport_counters_as_deltas: trueemit_tags_as_labels: true
3.7Rate Limit Service (RLS)
全局限速服务
配置方法:
apiVersion: networking.istio.io/v1alpha3kind: EnvoyFiltermetadata:name: filter-ratelimitnamespace: istio-systemspec:workloadSelector:labels:istio: ingressgatewayconfigPatches:- applyTo: HTTP_FILTERmatch:context: GATEWAYlistener:filterChain:filter:name: "envoy.filters.network.http_connection_manager"subFilter:name: "envoy.filters.http.router"patch:operation: INSERT_BEFOREvalue:name: envoy.filters.http.ratelimittyped_config:"@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimitdomain: productpage-ratelimitfailure_mode_deny: truerate_limit_service:grpc_service:envoy_grpc:cluster_name: rate_limit_clustertimeout: 10stransport_api_version: V3- applyTo: CLUSTERmatch:cluster:service: ratelimit.istio.svc.cluster.localpatch:operation: ADDvalue:name: rate_limit_clustertype: STRICT_DNSconnect_timeout: 10slb_policy: ROUND_ROBINhttp2_protocol_options: {}load_assignment:cluster_name: rate_limit_clusterendpoints:- lb_endpoints:- endpoint:address:socket_address:address: ratelimit.istio.svc.cluster.localport_value: 8081
3.8Runtime Discovery Service (RTDS)
运行时发现服务
配置方法
layered_runtime:layers:- rtds_layer:name: rtds_namertds_config:ads: {}initial_fetch_timeout: 15sresource_api_version: V3
3.9Client Status Discovery Service (CSDS)
客户端状态发现服务
3.10Tap Sink Service
tap槽服务
3.11Trace service
链路跟踪服务
配置方法:
apiVersion: v1data:mesh: |-accessLogFile: /dev/stdoutenableTracing: truedefaultConfig:discoveryAddress: istiod.istio-system.svc:15012meshId: mesh1proxyMetadata: {}tracing:sampling: 100zipkin:address: zipkin.istio-system:9411enablePrometheusMerge: trueenableTracing: truerootNamespace: istio-systemtrustDomain: cluster.localmeshNetworks: 'networks: {}'
3.12Extension Config Discovery Service (ECDS)
扩展配置发现服务
配置方法:
apiVersion: networking.istio.io/v1alpha3kind: EnvoyFiltermetadata:name: wasm-examplenamespace: mynsspec:configPatches:# The first patch defines a named Wasm extension and provides a URL to fetch Wasm binary from,# and the binary configuration. It should come before the next patch that applies it.# This resource is visible to all proxies in the namespace "myns". It is possible to provide# multiple definitions for the same name "my-wasm-extension" in multiple namespaces. We recommend that:# - if overriding is desired, then the root level definition can be overriden per namespace with REPLACE.# - if overriding is not desired, then the name should be qualified with the namespace "myns/my-wasm-extension",# to avoid accidental name collisions.- applyTo: EXTENSION_CONFIGpatch:operation: ADD # REPLACE is also supported, and would override a cluster level resource with the same name.value:name: my-wasm-extensiontyped_config:"@type": type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasmconfig:root_id: my-wasm-root-idvm_config:vm_id: my-wasm-vm-idruntime: envoy.wasm.runtime.v8code:remote:http_uri:uri: http://my-wasm-binary-uriconfiguration:"@type": "type.googleapis.com/google.protobuf.StringValue"value: |{}# The second patch instructs to apply the above Wasm filter to the listener/http connection manager.- applyTo: HTTP_FILTERmatch:context: SIDECAR_INBOUNDpatch:operation: ADDfilterClass: AUTHZ # This filter will run *after* the Istio authz filter.value:name: my-wasm-extension # This must match the name aboveconfig_discovery:config_source:api_config_source:api_type: GRPCtransport_api_version: V3grpc_services:- envoy_grpc:cluster_name: xds-grpctype_urls: ["envoy.extensions.filters.http.wasm.v3.Wasm"]
3.13External Processing Service
外部处理服务,他允许使用一个外部grpc服务来处理请求,修改头或体,或者直接响应连接。
配置方法:
apiVersion: networking.istio.io/v1alpha3kind: EnvoyFiltermetadata:name: bandthspec:workloadSelector:labels:istio: ingressgatewayconfigPatches:- applyTo: HTTP_FILTERmatch:context: GATEWAYlistener:portNumber: 8080filterChain:filter:name: "envoy.filters.network.http_connection_manager"subFilter:name: "envoy.filters.http.router"patch:operation: INSERT_BEFOREvalue:name: envoy.filters.http.ext_proctyped_config:"@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessorgrpc_service:envoy_grpc:cluster_name: external-server.istio.svc.cluster.localtimeout: 3sfailure_mode_allow: truemessage_timeout: 200ms
3.14Aggregated Discovery Service (ADS)
ads是cds,lds,rds,eds的总称。
配置方式
dynamic_resources:ads_config:api_type: GRPCgrpc_services:- envoy_grpc:cluster_name: xds-grpcset_node_on_first_message_only: truetransport_api_version: V3
3.15Cluster discovery service (CDS)
cds是集群发现服务,用于发现cluster,然后发送到envoy
配置方式:
dynamic_resources:cds_config:ads: {}initial_fetch_timeout: 0sresource_api_version: V3
3.16gRPC Event Reporting Service
事件报告服务
3.17Listener discovery service (LDS)
lds是监听器发现服务,用于发现listener,然后发送到envoy
配置方式:
dynamic_resources:lds_config:ads: {}initial_fetch_timeout: 0sresource_api_version: V3
3.18Route discovery service (RDS)
rds是路由发现服务,用于发现路由,然后发送到envoy
配置方式
route_config_name: some_route_nameconfig_source:resource_api_version: V3api_config_source:api_type: GRPCtransport_api_version: V3grpc_services:envoy_grpc:cluster_name: some_xds_cluster
3.19Secret discovery service (SDS)
sds是secret发现服务,用于发现secret,然后发送到envoy
配置方式:
name: some_secret_nameconfig_source:resource_api_version: V3api_config_source:api_type: GRPCtransport_api_version: V3grpc_services:envoy_grpc:cluster_name: some_xds_cluster
3.20Virtual Host Discovery Service (VHDS)
vhds是虚拟主机发现服务,用于发现virtual host,然后发送到envoy
配置方式:
apiVersion: networking.istio.io/v1alpha3kind: EnvoyFiltermetadata:name: httpconnectionmanagerspec:workloadSelector:labels:istio: ingressgatewayconfigPatches:- applyTo: NETWORK_FILTERmatch:context: GATEWAYlistener:portNumber: 8080filterChain:filter:name: "envoy.filters.network.http_connection_manager"patch:operation: MERGEvalue:name: envoy.filters.network.http_connection_managertypedConfig:'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManagerroute_config:name: testvhds:config_source:ads: {}initial_fetch_timeout: 15s
3.21Endpoint discovery service(eds)
eds是endpoint 发现服务,用于发现endpoint,然后发送到envoy
配置方式
eds_config:resource_api_version: V3api_config_source:api_type: RESTtransport_api_version: V3cluster_names: [some_xds_cluster]




