Kubernetes Ingress Compression
Enabling Gzip/Brotli in ingress-nginx
Mon Jun 12 2023
I ran a few tests on this site with Lighthouse and realized that I hadn’t enabled text compression, so I looked into how to do that with the Kubernetes ingress-nginx controller that serves it. It was super simple I just had to add some settings to the ConfigMap for the ingress controller.
Use the following to get a copy of the existing controller configuration:
kubectl get configmap ingress-nginx-controller -n ingress-nginx -o yaml
Edit the file to add use-gzip: "true"
and enable-brotli: "true"
:
apiVersion: v1
data:
allow-snippet-annotations: "true"
use-proxy-protocol: "true"
use-gzip: "true"
enable-brotli: "true"
kind: ConfigMap
metadata:
name: ingress-nginx-controller
namespace: ingress-nginx
Apply the configuration change:
kubectl apply -f configmap-ingress-nginx-controller.yml
Bingo Bango! We have compression happening when I look at the Network tab in Chrome Devtools:
It was an easy win!