简介
开始阶段咱们在kubernetes
中应用ingress-nginx
来提供http
对外暴漏服务,因为服务网格的风行,开始将ingress
切换了istio
,通常只是应用了gateway
和vs
相干性能和一些网络鉴权性能,前期业务需要,须要http
压缩性能,所以须要开启istio
的gzip
性能,经官网文档istio
默认时没有开启压缩的性能,然而能够通过EnvoyFilter
来对代理进行插件扩大。
环境
- kubernetes1.18版本
- istio 1.10.1版本。
压缩计划
gateway
进行压缩,对此gateway
下的http
业务对立都进行压缩。sidecat
压缩,对指定业务进行压缩。
单个压缩
apiVersion: networking.istio.io/v1alpha3kind: EnvoyFiltermetadata: name: gzipspec: workloadSelector: labels: app: productpage #抉择你要压缩的利用 configPatches: - applyTo: HTTP_FILTER #指定利用envoy配置中的补丁地位 match: context: SIDECAR_INBOUND #sidercar入站的路由监听集群 listener: filterChain: #匹配监听器中特定的过滤链 filter: #要利用补丁的特定过滤器的名称 name: envoy.filters.network.http_connection_manager #匹配的过滤器名称 subFilter: #匹配上级过滤器名称 name: envoy.filters.http.router patch: operation: INSERT_BEFORE #进行的操作 进行插入操作 value: ### 插入envoy配置 name: envoy.filters.http.compressor typed_config: '@type': type.googleapis.com/envoy.extensions.filters.http.compressor.v3.Compressor response_direction_config: common_config: content_type: - text/html - text/css - application/javascript disable_on_etag_header: true request_direction_config: common_config: enabled: default_value: false runtime_key: request_compressor_enabled compressor_library: name: text_optimized typed_config: '@type': type.googleapis.com/envoy.extensions.compression.gzip.compressor.v3.Gzip compression_level: BEST_COMPRESSION compression_strategy: DEFAULT_STRATEGY
网关压缩
kind: EnvoyFilter metadata: name: gzip namespace: istio-system spec: workloadSelector: labels: app: istio-ingressgateway configPatches: - applyTo: HTTP_FILTER match:- context: SIDECAR_INBOUND+ context: GATEWAY listener: filterChain: filter: name: envoy.filters.network.http_connection_manager #匹配的过滤器名称 subFilter: #匹配上级过滤器名称 name: envoy.filters.http.router patch: operation: INSERT_BEFORE #进行的操作 进行插入操作 value: ### 插入envoy配置 name: envoy.filters.http.compressor typed_config: '@type': type.googleapis.com/envoy.extensions.filters.http.compressor.v3.Compressor response_direction_config: common_config: content_type: - text/html - text/css - application/javascript disable_on_etag_header: true request_direction_config: common_config: enabled: default_value: false runtime_key: request_compressor_enabled compressor_library: name: text_optimized typed_config: '@type': type.googleapis.com/envoy.extensions.compression.gzip.compressor.v3.Gzip compression_level: BEST_COMPRESSION compression_strategy: DEFAULT_STRATEGY
参考文档
- https://www.envoyproxy.io/doc...
- https://istio.io/latest/docs/...