-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support for zstd compression #2313
Add support for zstd compression #2313
Conversation
pkg/config/options.go
Outdated
@@ -68,6 +68,8 @@ type KanikoOptions struct { | |||
ImageNameDigestFile string | |||
ImageNameTagDigestFile string | |||
OCILayoutPath string | |||
Compression string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a CompressionLevel
type like you have in the go-containerregistry change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we expose the Compression
type in the go-containerregistry package I'll just use this type. Otherwise I'll create a new one in this codebase.
936c4dd
to
ce7a41d
Compare
dbc0ffa
to
69f3e3f
Compare
7d37432
to
3e83d37
Compare
Is there much activity on this project these days? I'd love to see this PR merged. (Should the README be updated with new flags, by the way?) |
Yes, I'd like to proceed with this PR. @imjasonh could you trigger the automatic checks please? |
Thanks @imjasonh for triggering the tests. I'm having a hard time fixing the unit tests on my machine. It seems like the vagrant setup doesn't work on M2 cpus :/ Did anyone have this issue before? |
390fc06
to
e93ce25
Compare
Ok, I've now created a proper test setup on debian. I'm pretty sure that i'm doing everything right, but the I tried running the
I tried upgrading the linter to a more recent version and while that seems to resolve the cryptic error message above, it results in new lint errors. Could it be that there is still something wrong with my test setup? I don't quite understand why i'm getting lint and gofmt errors on a version of the repo that has already been released. |
…ompression level We want to make the layer compression in kaniko configurable, so we have added two optional command line arguments “--compression” and “--compression-level”. The former allows the user to specify a compression algorithm (zstd, gzip) and the latter can be used to specify the compression level. Depending on the selected compression algorithm and level we modify the set of layerOptions that are used to create tarball layers in `push.go` and `build.go`. The actual implementation of the zstd support can be found in our fork of the go-containerregistry package for which we have filed this PR: google/go-containerregistry#1487 The changes should be fully backwards compatible.
This change will ensure that users can only specify supported compression algorithms (`zstd`, `gzip`) to the `--compression` flag.
e93ce25
to
8346fba
Compare
Regarding my previous message: I realized that my changes weren't based on the v1.9.1 release, but on a more recent commit on the main branch which also suffers from the same linting issues. I thought I made my changes on top of v1.9.1 which is why i was so confused. Earlier today I saw that there was some activity on main that seems to address the issues (many thanks to everyone who is working on this), so I rebased my changed onto the latest commit on main. |
Glad to see this picking up again :) As and when there's a good time, I'd be glad to test for my use case. Not sure if an actual gcr.io image will be generated from this PR -- or even if merged -- but if I'd have to build the image myself, I can work that out if needed. |
Sorry to be a bother with this, but could you trigger the checks again please, @imjasonh? |
Thanks @imjasonh for triggering the tests. The results looked much better than the test runs before that. I fixed the issues that popped up in the previous unit test. Would you mind restarting the tests once again? Thanks a lot! |
* Add support for configurable compression algorithm (gzip, zstd) and compression level We want to make the layer compression in kaniko configurable, so we have added two optional command line arguments “--compression” and “--compression-level”. The former allows the user to specify a compression algorithm (zstd, gzip) and the latter can be used to specify the compression level. Depending on the selected compression algorithm and level we modify the set of layerOptions that are used to create tarball layers in `push.go` and `build.go`. The actual implementation of the zstd support can be found in our fork of the go-containerregistry package for which we have filed this PR: google/go-containerregistry#1487 The changes should be fully backwards compatible. * Restrict inputs for compression flag to gzip and zstd This change will ensure that users can only specify supported compression algorithms (`zstd`, `gzip`) to the `--compression` flag. * Fix incorrect type for switch statements on config.Compression
It it true that this PR doesn't add zstd:chunked support? |
It only adds regular zstd compression. The underlying compression logic can be found here: google/go-containerregistry#1487 |
Description
This PR adds support for zstandard compression to kaniko. We have modified the
go-containerregistry
package to add support for zstd compressed tarball image layers. The PR (google/go-containerregistry#1487) is currently being reviewed.We have added two additional command line arguments
--compression
and--compression-level
which can be used to select the compression algorithm (gzip
orzstd
) and specify a numeric compression level. To ensure full backwards compatibility,gzip
will be used by default.Please note that we had to bump the version of google/go-containerregistry to v0.13.0 and cloud.google.com/go/storage to v1.26.0 which caused a couple of other dependencies to be upgraded as well.
So far, we ran some manual tests but haven't added automated tests yet. If you have any suggestions or pointers regarding test, especially integration tests, please let us know.
To give some more context:
We are adding zstd support to Northflank CI/CD & Images. We have built support for multiple build engines including Buildkit, Kaniko and CNBPs. Buildkit already supports zstd, but Kaniko does not. This PR implements zstd support for Kaniko which outperformed gzip in both performance and compression ratio in our tests.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Reviewer Notes
Release Notes
Describe any changes here so maintainer can include it in the release notes, or delete this block.