Enabling GZIP compression with Istio

Çağatay Gürtürk
1 min readDec 11, 2020

Although Istio documentation does not specify how to enable GZIP compression, it is in fact possible to enable it via the built-in Compressor filter.

Assuming that you want to enable GZIP compression on specific applications, the following EnvoyFilter manifest will do the trick:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: gzip
spec:
workloadSelector:
labels:
# Put same labels that will identify your application
app.kubernetes.io/instance: my-application
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
filterChain:
filter:
name: envoy.http_connection_manager
subFilter:
name: envoy.router
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.compressor
typed_config:
# See https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/compressor_filter for full options
'@type': type.googleapis.com/envoy.extensions.filters.http.compressor.v3.Compressor
compressor_library:
name: text_optimized
typed_config:
'@type': type.googleapis.com/envoy.extensions.compression.gzip.compressor.v3.Gzip
remove_accept_encoding_header: true

It is also possible to enable the compression globally at Istio gateway level. For that, you can replace “context” with “GATEWAY” and switch workloadSelector to a selector that will match to Istio gateways. (e.g. app: istio-ingressgateway)

typed_config is an important field where you can configure the filter. There are quite some configuration options you can check at the filter documentation. I am enabling remove_accept_encoding_header to make sure that the sidecar proxy strips away the Accept-Encoding header, so my application, if it accepts this header, does not attempt to compress the response.

--

--

Çağatay Gürtürk

Senior Cloud Architect @epam, formerly Software Development Manager @ebay. Author of Building Serverless Architectures.