Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disableCompression: Expose configuration to toggle Envoy GZIP compression on the responses #6546

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

chaosbox
Copy link

@chaosbox chaosbox commented Jul 9, 2024

For #6511

This PR adds,

  • Listener configuration that exposes a boolean flag to disable compression, by default compression is enabled. This also provides us a way to disable if the users prefer to trade network for CPU, especially when teams want to run lean Envoy instances and rely on horizontal scalability.
  • We will run the test build for a while in our cluster to show the actual cost benefit.

Related #310, there had been mentions about disabling compression, the ticket we had raised shows the reason where disabling compression can bring cost benefits.

@chaosbox chaosbox requested a review from a team as a code owner July 9, 2024 09:04
@chaosbox chaosbox requested review from skriss and sunjayBhatia and removed request for a team July 9, 2024 09:04
@sunjayBhatia sunjayBhatia requested review from a team, rajatvig and davinci26 and removed request for a team July 9, 2024 09:18
Copy link

github-actions bot commented Jul 9, 2024

Hi @chaosbox! Welcome to our community and thank you for opening your first Pull Request. Someone will review it soon. Thank you for committing to making Contour better. You can also join us on our mailing list and in our channel in the Kubernetes Slack Workspace

dependabot bot and others added 2 commits July 9, 2024 10:42
…jectcontour#6543)

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@d70bba7...4fd8129)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: chaosbox <[email protected]>
Copy link

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 14d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Ensure your PR is passing all CI checks. PRs that are fully green are more likely to be reviewed. If you are having trouble with CI checks, reach out to the #contour channel in the Kubernetes Slack workspace.
  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2024
@chaosbox
Copy link
Author

Ping

@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 29, 2024
@tsaarni tsaarni added the release-note/small A small change that needs one line of explanation in the release notes. label Aug 2, 2024
# Conflicts:
#	.github/workflows/build_main.yaml
#	.github/workflows/build_tag.yaml
#	.github/workflows/prbuild.yaml
Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've included suggestions inline for some linter nags (link).

Please add the new disableCompression option in "Configuration File" chapter in site/content/docs/main/configuration.md.

Please add also a changelog file.

internal/featuretests/v3/compression_test.go Outdated Show resolved Hide resolved
internal/featuretests/v3/compression_test.go Outdated Show resolved Hide resolved
test/e2e/httpproxy/envoy_compression_test.go Outdated Show resolved Hide resolved
test/e2e/httpproxy/envoy_compression_test.go Outdated Show resolved Hide resolved
test/e2e/httpproxy/envoy_compression_test.go Outdated Show resolved Hide resolved
},
ResponseDirectionConfig: &envoy_filter_http_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_filter_http_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: []string{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible alternative approach could be to leave the compressor filter in the chain but disable it by setting default to false in ResponseDirectionConfig.CommonConfig.Enabled

Enabled: &envoy_config_core_v3.RuntimeFeatureFlag{
	// If compression is enabled add compressor filter
	DefaultValue: wrapperspb.Bool(!b.disableCompression),
	RuntimeKey:   "contour.compression.response.enabled",
},

but since we do not have "per route" setting, which would override the default, it make sense to me that the whole filter is excluded from the chain when disabled, like suggested in this PR currently.

Copy link

@geomacy geomacy Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, given

since we do not have "per route" setting

the thought in this PR is to work at the level of the whole filter. The functionality could be extended as described above if needed in future but that would best be left to another PR.

@geomacy
Copy link

geomacy commented Aug 19, 2024

Thanks very much for the feedback @tsaarni 🙇 we'll have a look at this and try to get back with updates as soon as possible.

@geomacy
Copy link

geomacy commented Aug 21, 2024

Many thanks for taking the time to provide the lint fixes. We'll update the docs and add the changelog as soon as possible.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 84.84848% with 10 lines in your changes missing coverage. Please review.

Project coverage is 81.75%. Comparing base (54ceade) to head (36dbadb).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
cmd/contour/servecontext.go 45.45% 6 Missing ⚠️
cmd/contour/serve.go 33.33% 2 Missing ⚠️
pkg/config/parameters.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6546      +/-   ##
==========================================
- Coverage   81.76%   81.75%   -0.02%     
==========================================
  Files         133      133              
  Lines       15944    15986      +42     
==========================================
+ Hits        13037    13069      +32     
- Misses       2614     2623       +9     
- Partials      293      294       +1     
Files with missing lines Coverage Δ
internal/contourconfig/contourconfiguration.go 98.70% <100.00%> (+<0.01%) ⬆️
internal/envoy/v3/listener.go 98.51% <100.00%> (+0.05%) ⬆️
internal/xdscache/v3/listener.go 92.20% <100.00%> (+0.08%) ⬆️
cmd/contour/serve.go 22.71% <33.33%> (+0.04%) ⬆️
pkg/config/parameters.go 87.50% <60.00%> (-0.54%) ⬇️
cmd/contour/servecontext.go 84.77% <45.45%> (-1.17%) ⬇️

@geomacy geomacy force-pushed the main branch 3 times, most recently from 619ac16 to 16f72d7 Compare August 22, 2024 16:38
Geoff Macartney and others added 5 commits August 22, 2024 17:46
Co-authored-by: Tero Saarni <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Co-authored-by: Tero Saarni <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Co-authored-by: Tero Saarni <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Co-authored-by: Tero Saarni <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Co-authored-by: Tero Saarni <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just small documentation comments.

Comment on lines 351 to 352
// DisableCompression disables GZIP compression HTTP filter from the default Listener filters
// Setting this true will enable Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// DisableCompression disables GZIP compression HTTP filter from the default Listener filters
// Setting this true will enable Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response
// DisableCompression disables GZIP compression HTTP filter from the default Listener filters.
// Setting this true will enable Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response.

@@ -0,0 +1 @@
Add disableCompression boolean flag to disable GZIP compression HTTP filter from the default Listener filters.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog entry could mention where the flag can be found

Suggested change
Add disableCompression boolean flag to disable GZIP compression HTTP filter from the default Listener filters.
Add disableCompression boolean flag in the ContourConfiguration CRD and in configuration file to disable GZIP compression HTTP filter, forcing Envoy to always return uncompressed response.

Copy link
Contributor

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for commenting so late in the process but I think given that there are a lot of compression algorithms supported by envoy. Some of them much better than gzip like zstd I think we might want to change the api to allow the user to choose the compression algorithm and have an option called nocompression that disables it

@aecay
Copy link

aecay commented Aug 27, 2024

@davinci26 that's an interesting idea. It goes beyond what was mentioned in #310 which -- although it's far from a formal design process (so early in contour's lifecylce) -- is at least some semblance of a "blessing" of the API change in this PR. If we were to go for the alternative API you proposed (which is IMO richer/better overall), would it require going through the proposal process since it's not something that has been (afaik) so far envisioned/discussed?

@geomacy
Copy link

geomacy commented Oct 9, 2024

Hi @davinci26 @tsaarni I have updated the branch according to your comment above, so that it is now possible to request different types of compression, including none. Rather than a separate nocompression flag, I've just provided an additional compression option "disabled".

The supported types of compression are those included in go-control-plane/envoy/extensions/compression, namely

  • gzip
  • brotli
  • zstd

This can be configured with the flag --compression or in config.

In-cluster tests

Tests against a deployment of "podinfo" on an in-house cluster.

out-of-the-box default behaviour

Ask for gzip encoding and gunzip the output:

~ [56]$ curl -v -H 'Accept-Encoding: gzip,deflate'  $URL/env | gzip -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 08 Oct 2024 13:41:14 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: gzip
< vary: Accept-Encoding
< server: envoy
<
{ [283 bytes data]
100   293    0   293    0     0   1421      0 --:--:-- --:--:-- --:--:--  1422
...
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "HOSTNAME=podinfo-9f86b555d-c6cz7",
  "PODINFO_UI_COLOR=#34577c",

Note the content-encoding: gzip in the response - default behaviour is to gzip responses in response to the accept encoding request header.

disabled

set the flag in config (we hold values for the config in a configmap):

apiVersion: v1
data:
  contour.yaml: |-
    compression: disabled
    accesslog-format: json
...

Repeat the command above but this time should get text back and not need to un-gzip:

~ $ curl -v -H 'Accept-Encoding: gzip,deflate'  $URL/env
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 08 Oct 2024 13:50:11 GMT
< content-length: 814
< x-envoy-upstream-service-time: 1
< server: envoy
<
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "HOSTNAME=podinfo-9f86b555d-c6cz7",
  "PODINFO_UI_COLOR=#34577c",
  "PODINFO_SERVICE_HOST=192.168.243.43",

No content-encoding: gzip in the response. Compression has been disabled.

brotli

Request brotli encoding on the response and decode it with the brotli CLI tool:

~ $ curl -v -H 'Accept-Encoding: br,deflate'  $URL/env | brotli -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 08 Oct 2024 13:53:45 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: br
< vary: Accept-Encoding
< server: envoy
<
{ [287 bytes data]
100   288    0   288    0     0   1020      0 --:--:-- --:--:-- --:--:--  1021
...
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "HOSTNAME=podinfo-9f86b555d-c6cz7",
  "PODINFO_UI_COLOR=#34577c",

Note content-encoding: br in the response headers and the successful decode of the response. Brotli encoding was successfully requested.

zstd

Request zstd encoding on the response and decode it with the zstd CLI tool:

~ $ curl -v -H 'Accept-Encoding: zstd,deflate'  $URL/env | zstd -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 08 Oct 2024 14:03:27 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: zstd
< vary: Accept-Encoding
< server: envoy
<
{ [302 bytes data]
100   302    0   302    0     0   1089      0 --:--:-- --:--:-- --:--:--  1090
...
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "HOSTNAME=podinfo-9f86b555d-c6cz7",

Note the content-encoding: zstd in the response headers and the successful decompression.
zstd encoding was successfully requested.

Invalid setting

Test the validation on the compression setting in contour config. Set an invalid value for the compression flag and restart contour pods. Pods fail to start with a simple error message recording the invalid value:

~ $ kubectl --context sky-pre-dev-euwest1 -n contour-main-external logs  contour-contour-6fc5b659c5-22d5g
time="2024-10-08T14:07:11Z" level=info msg="maxprocs: Leaving GOMAXPROCS=16: CPU quota undefined"
contour: error: invalid Contour configuration: invalid compression type: "bogus", try --help

@geomacy
Copy link

geomacy commented Oct 9, 2024

Could you kindly review and enable the build workflows on this to see if they all pass? In the branch where it was built I was getting an odd error on the upgrade tests, as noted here, and I wasn't sure if that might be because that was just a branch.

The upgrade tests are failing with

./test/scripts/kind-load-contour-image.sh
fatal: No names found, cannot describe anything.
CONTOUR_UPGRADE_FROM_VERSION= \
	CONTOUR_E2E_IMAGE=ghcr.io/projectcontour/contour:7e843b7a \
	go run github.com/onsi/ginkgo/v2/ginkgo -tags=e2e -mod=readonly -randomize-all -poll-progress-after=300s -v ./test/e2e/upgrade

Not 100% sure why that is, possibly something to do with actions/checkout on a branch? I think this change is sufficiently
advanced to make it worth merging to chaosbox/main, and working on resolving any futher test failures there.

Copy link
Contributor

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some small comments but I think this is in the correct direction

// Values: `gzip` (default), `brotli`, `zstd`, `disabled`.
// Setting this to `disabled` will make Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response
// +optional
Compression EnvoyCompressionType `json:"compression,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use // +kubebuilder:validation:Enum=gzip,brotli,zstd,disabled as well?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 sounds good, I will add that

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @davinci26 added this in f7b261b

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

$ kubectl apply -f - <<-EOF
> apiVersion: projectcontour.io/v1alpha1
kind: ContourConfiguration
metadata:
  name: example-contour-config-1
spec:
  envoy:
    listener:
      compression: bogus
EOF
The ContourConfiguration "example-contour-config-1" is invalid: spec.envoy.listener.compression: Unsupported value: "bogus": supported values: "gzip", "brotli", "zstd", "disabled"

// Values: `gzip` (default), `brotli`, `zstd`, `disabled`.
// Setting this to `disabled` will make Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response
// +optional
Compression EnvoyCompressionType `json:"compression,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API here is fairly constrained so we might want to think through how would we extend it if anyone comes up with the feature request to tune the API on different compression levels

I think adding another field called Compression Strategy might be fine or create a struct that right now has a single object

Compression *EnvoyCompression `json:"compression,omitempty"`
Member

type  EnvoyCompression struct {
Aglorithm Algorithm `json:"algorithm,omitempty"
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think (briefly) about making the configurability greater, and/or having a wider range of compression algorithms. In the end I decided against it, at least for this PR -

  • while one could add more compression algorithms I thought that exposing the ones from envoy/extensions was a nice and easily explained choice. There are a couple of others in contrib/envoy/extensions but gzip/br/zstd seems like the ones that are most likely to be widely wanted. And I certainly didn't want to start thinking about making the algorithm choice be more "pluggable"!
  • as for configurability of algorithms I thought it wasn't something I felt I wanted to start making decisions on - I expect contour project members would perhaps not want to expose all the configuration options for every algorithm, but then this leaves you with the question of how to sensibly define some configuration that supports enough configurability for the different algorithms. It felt like a bit of a rabbit hole and I thought it would be something kept separate from this PR - better to try to keep changes as small as possible, and this one is meaty enough already.

Believe it or not I actually took a bit of inspiration from the Contour Philosophy 😆 (I did read around on how to contribute), particularly the bit on Sensible Defaults. I felt these kind of gave permission to simply offer a choice of a few widely used algorithms, using default settings. While a strategy field could be added here, it would be something of a no-op feature unless we took the time to implement at least basic configurability in it. I feel this would be best left to another PR. Would that be OK?

Copy link

@geomacy geomacy Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also now that I think of it, the feature here of most interest to us in our project is the compression disabling, so from an admittedly selfish point of view I would like to leave the configurability to a separate bit of work. Like everyone else we're very busy, and I have ended up having to do most of this work in my own time in the evenings and weekends :-(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be transparent I dont want to design how we extend it but I am trying to think through if we leave enough space to extend the api.

In the end I decided against it, at least for this PR

My only issue is that if we go with the approach here and in 3 months we wanted to add another compression knob then we have two options:

  • Make a breaking change which might be fine due to the fact that this is a v1alpha1 package.
  • Add the option topline object in type EnvoyListenerConfig struct

If we think that these are fine options I think the api is good. I am just proponent of adding another struct that has a single member so we can extend just that struct

Like everyone else we're very busy, and I have ended up having to do most of this work in my own time in the evenings and weekends :-(

Yeah, a lot of the people contributing to this project to this into this capacity so I feel you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will defer to @projectcontour/maintainers

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah now that you have laid it out like that I see what you mean. Let me take a look at it, hopefully this wouldn't be too large a change.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @davinci26 I have taken a stab at this in 5dcdc33, could you have a look and see what you think?

Copy link

@geomacy geomacy Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to test this, I see some failures in e2e and will want also to run it on a local cluster, will try to get that done this week and add results in a comment.

@@ -471,6 +473,8 @@ func (s *Server) doServe() error {
SocketOptions: contourConfiguration.Envoy.Listener.SocketOptions,
}

s.log.WithField("context", "listenerConfig").Infof("compression setting: %s", listenerConfig.Compression)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this from debugging?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually left this in here deliberately - I think it's quite nice to be able to see the choice of algorithm reflected in the initial log output. But if that's not a typical contour thing to do I'll take it out. Let me know what would be preferred.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took this out in b68f0b1

Geoff Macartney added 2 commits October 19, 2024 12:41
Signed-off-by: Geoff Macartney <[email protected]>
Copy link
Contributor

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have one api comment that I left open but I think the code overall lgtm and useful.

@@ -0,0 +1 @@
Add "compression" flag to set/disable the compression type applied in the default HTTP filter chain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might need update as well based on the new api

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included in 5dcdc33

Geoff Macartney added 3 commits October 23, 2024 17:59
Signed-off-by: Geoff Macartney <[email protected]>
Avoid NPE in parameters.Validate

also tidy flag handling in registerServe, don't set compression struct unless parameter is supplied.

Signed-off-by: Geoff Macartney <[email protected]>
@geomacy
Copy link

geomacy commented Oct 25, 2024

Have added one more fix of a test, but I still need to finish testing on-cluster, will update the ticket when I get that completed.

Geoff Macartney added 5 commits October 28, 2024 10:10
Signed-off-by: Geoff Macartney <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
Signed-off-by: Geoff Macartney <[email protected]>
@geomacy
Copy link

geomacy commented Oct 29, 2024

Hello @davinci26 @tsaarni, I have updated the code per the proposal to support better API extensibility by wrapping the settings in a struct. I believe this PR is ready for review. Some results below from testing on a cluster:

default

out of the box behaviour

curl -v -H "Accept-Encoding: gzip,deflate"  $URL | gzip -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:36:04 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: gzip
< vary: Accept-Encoding
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

response was gzip.

parameter disabled

added to container args:

        - --compression=disabled

curl:

$ curl -v -H "Accept-Encoding: gzip,deflate"  $URL
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:40:55 GMT
< content-length: 353
< x-envoy-upstream-service-time: 1
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

No compression applied, it has been disabled.

parameter gzip

set container args to have

        - --compression=gzip

curl

$ curl -v -H "Accept-Encoding: gzip,deflate"  $URL | gzip -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:44:05 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: gzip
< vary: Accept-Encoding
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

parameter brotli

set container args to have

        - --compression=brotli

curl

$ curl -v -H "Accept-Encoding: br,deflate"  $URL | brotli -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:46:35 GMT
< x-envoy-upstream-service-time: 2
< content-encoding: br
< vary: Accept-Encoding
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

brotli encoding applied

parameter zstd

set container args with

        - --compression=zstd

curl

$ curl -v -H "Accept-Encoding: zstd,deflate"  $URL | zstd -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:49:23 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: zstd
< vary: Accept-Encoding
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

zstd encoding applied

config disabled

Remove compression flag from container args and set config map to have:

apiVersion: v1
data:
  contour.yaml: |-
    compression:
      algorithm: disabled
    ...

Restart contour pods. Do curl requesting gzip

$ curl -v -H "Accept-Encoding: gzip,deflate"  $URL
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:54:23 GMT
< content-length: 353
< x-envoy-upstream-service-time: 1
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",
  "version": "6.0.0",

compression is disabled.

config gzip

edit config

apiVersion: v1
data:
  contour.yaml: |-
    compression:
      algorithm: gzip
    ...

Restart contour and curl:

$ curl -v -H "Accept-Encoding: gzip,deflate"  $URL | gzip -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:56:37 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: gzip
< vary: Accept-Encoding
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

response encoded with gzip

config brotli

edit config to

apiVersion: v1
data:
  contour.yaml: |-
    compression:
      algorithm: brotli

Restart contour and curl:

$ curl -v -H "Accept-Encoding: br,deflate"  $URL | brotli -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 09:59:48 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: br
< vary: Accept-Encoding
< server: envoy
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

config zstd

edit config to

apiVersion: v1
data:
  contour.yaml: |-
    compression:
      algorithm: zstd

curl:

$ curl -v -H "Accept-Encoding: zstd,deflate"  $URL | zstd -d
...
< HTTP/2 200
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< date: Tue, 29 Oct 2024 10:29:20 GMT
< x-envoy-upstream-service-time: 1
< content-encoding: zstd
< vary: Accept-Encoding
< server: envoy
<
{
  "hostname": "podinfo-5bd5b49f6d-n847k",

zstd compression applied.

@geomacy
Copy link

geomacy commented Nov 5, 2024

Hello @tsaarni, @davinci26, would you be able to review this? Thanks.

@davinci26
Copy link
Contributor

@geomacy will take a look later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants