简介

开始阶段咱们在kubernetes中应用ingress-nginx来提供http对外暴漏服务,因为服务网格的风行,开始将ingress切换了istio,通常只是应用了gatewayvs相干性能和一些网络鉴权性能,前期业务需要,须要http压缩性能,所以须要开启istiogzip性能,经官网文档istio默认时没有开启压缩的性能,然而能够通过EnvoyFilter来对代理进行插件扩大。

环境

  • kubernetes1.18版本
  • istio 1.10.1版本。

压缩计划

  1. gateway进行压缩,对此gateway下的http业务对立都进行压缩。
  2. 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 

参考文档

  1. https://www.envoyproxy.io/doc...
  2. https://istio.io/latest/docs/...