Commit Graph

80 Commits

Author SHA1 Message Date
Matheus Pimenta 8bbd69d8a1
Add --push-ignore-immutable-tag-errors boolean CLI option (#2774) 2024-02-29 10:05:58 -08:00
Manish Giri 7bfc73c3ad
fix: Remove references to deprecated io/ioutil pkg (#2867)
* Update benchmark_test

* Updae tar.go

* Update further refs

* Commit next set of replacements

* Reverting changes in vendor folder

* Update integreation_with_context_test.go

* Update k8s_test.go

* Update remaining usages

* Replace conflicting usage of fs local variable
2023-11-28 13:02:53 -08:00
Lio李歐 e5395c7a21
feat: support https URLs for digest-file (#2811)
This feature allows one to specify an https URL for any of the
digest-file options, resulting in an HTTP PUT to the provided
URL. This could for example be a (pre-signed) URL to S3 or GCS.

Currently the final digest is only written to the local filesystem,
which disappears and is not accessible when Kaniko is run in a
managed container service like AWS ECS.

By supporting https a single implementation supports all storage
services, without the need for special code for S3, GCS, etc..
2023-11-10 11:05:36 -08:00
JeromeJu 6ee84f128d
Change condition for the behavior when --no-push=true without --destinations (#2676)
This commit changes the condition check for the behavior when no-push is
set to true while destinations are needed. Prior this change, users would
have to set destinations even when noPush option is set to true. More
specifically, a workaround for tar files to be generated when --no-push is
true and destinations is empty is provided where a dummy destination would be
set.
2023-08-17 09:53:59 -07:00
Julian cefe99b92a
Added skip-push-permission flag (#2657)
Added skip-push-permission flag to conditionally disable push permission check on build start to accommodate for slow network policies
2023-08-15 11:23:16 -07:00
Eric 7525828ef9
Add mTLS (client cert) registry authentication (#2180)
* Add mTLS (client cert) support

Add support for Mutual TLS (mTLS) client certificate authentication.
The expected format of the new --registry-client-cert flag is the same
as the existing --registry-certificate flag, which will allow
different client certificates for different registries:

--registry-client-cert my.registry.url=/path/to/cert.crt,/path/to/key.key

* tidy: Rename mTLS (Client Cert) flag to be in line with others

This flag didn't describe that it was for the client certs uses with
the registry. Although this should be reasonably obvious, I like the
consistency with the other registry flag.

* test: Added unit tests for mTLS (Client Cert) loading

* test: Add 2 more tests for comma split formatting

since the comma splitting is a new portion of code let's make sure
that that format works well too in other cases

* tidy: Fix formatting of flag help text

* tidy: Made invalid cert format error consistent

I was running the tests and saw the message:

Failed to load client certificate/key '/path/to/client/certificate.cert' for my.registry.name, format is my.registry.name=/path/to/cert,/path/to/key

I then realized that it'd be a lot nicer if this showed the user what
they input, and how they should change it (rather than decomposing it:

Failed to load client certificate/key 'my.registry.name=/path/to/client/certificate.cert', expected format: my.registry.name=/path/to/cert,/path/to/key

* test: Fixed incorrect test argument

This didn't fail the test before because it's only attempting to show
that certs only get loaded and used for their associated registry but
it's important to keep this correct.

This case is covered by the test below, "RegistriesClientCertificates
incorrect cert format"

* doc: Add new flag to README.md

* mod: Fail to push if there was a problem loading client certs

Rather than warning that there was an issue, we should fail if the
requested client certificates were not found or failed to load.

This feels a lot better than waiting for the build to finish then
failing later.

* mod: Return an error if the certificate authority fails to load, just like client certs

The MakeTransport function was changed in the previous commit to
allow returning errors if there was a problem loading certificates,
rather than just print warnings.

This feels a lot better as you get the error immediately that there's
a problem to fix, rather than getting a warning, then later an error
that the server's certificate could not be verified.

* tidy: fix golint issues
2023-05-18 14:20:51 -07:00
Lavrenti Frobeen 24846d22b1
Use correct media type for zstd layers (#2459)
In my previous commits I forgot to override the media type for layers that are using zstd compression.
2023-04-03 11:34:26 -04:00
Lavrenti Frobeen 76afb70790
Add support for zstd compression (#2313)
* 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
2023-04-01 22:25:25 -04:00
Natalie Arellano 4d077e2a40
Provide `--cache-repo` as OCI image layout path (#2250)
* Adds the ability to provide `--cache-repo` as an OCI image layout path

- Adds cache.LayoutCache to implement cache.LayerCache interface
- When opts.CacheRepo has "oci:" prefix, instantiates a LayoutCache

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add integration test for layout cache

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Updates from PR review

Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-28 10:19:02 -04:00
Gabriel Nützi 323e616a67
fix: Refactor `LayersMap` to correct old strange code behavior (#2066)
* fix: Correct flatten function in layers

- Added a test.
- Cache current image, track deletes in `whiteouts` as well as normal adds in `layers`.
- Fix ugly delete behavior of `layerHashCache`.
  Delete it when crerating a new snapshot.
- Slight cleanup in `snapshot.go`.
- Format ugly `WalkFS` function.

* fix: Add symbolic link changes  to Hasher and CacheHasher

* fix: Better log messages

* fix(ci): Integration tests

* fix(ci): Add `--no-cache` to docker builds

* fix(ci): Pass credentials for error integration test

* np: Missing .gitignore in `hack`

* np: Capitalize every log message

- Correct some linting.

* fix: Key function

- Merge only last layer onto `currentImage`.

* fix: Remove old obsolete `cacheHasher`
2022-05-17 20:30:58 -04:00
Gabriel Nützi 7b50fc8a57
fix: Main (#2094) 2022-05-17 13:27:24 -04:00
Jason D'Amour 872758b8b0
feat: add flag to disable pushing cache (#2038) 2022-05-16 12:21:26 -07:00
Jason Hall 633f555c5c
Fix implicit GCR auth (#1856)
* Fix implicit GCR auth

* boilerplate
2021-12-28 20:34:32 -05:00
Jason Hall 129df249c9
Log full image ref by digest when pushing an image (#1857) 2021-12-28 07:13:11 -06:00
Tejal Desai cf4822c31c
Run docker_credentials_gcr in warmer (#1780)
* run docker_credentials_gcr in warmer

* fix tests

* fix dockerfiles

* fix boilerplate

* mend

* fix

* another lint
2021-10-19 12:25:42 -07:00
Janosch Maier 46e01340c2
Remove tarball.WithCompressedCaching flag to resolve OOM Killed error (#1722)
* Remove tarball.WithCompressedCaching flag to resolve OOM Killed error

Large images cannot be build as the kaniko container will be killed due to an OOM error. Removing the tarball compression drastically reduces the memory required to push large image layers. Fixes #1680

This change may increase the build time for smaller images. Therefore a command line option to trigger the compression or a more intelligent behaviour may be useful.

* Add new command line flag to toggle compressed caching

* Add unittest for build with --compressed-caching command line flag set to false
2021-10-19 00:14:06 -07:00
Vivek Kumar 6028f1c5ec
fix: create parent directories before writing digest files (#1612) 2021-04-13 14:41:54 -07:00
Lars Gröber 0477900feb
Fixes #1544 (#1597)
* Specifying a tarPath will push the image as well
2021-03-31 10:17:26 -07:00
Sascha Schwarze 69f942f751
Improve retry behavior for push operation (#1578)
* Update go-containerregistry to 0.4

* Implement --push-retry argument
2021-02-22 21:25:58 -08:00
Or Geva b3e036aab2
Add --image-name-tag-with-digest flag (#1541) 2021-01-19 13:28:05 -08:00
Josh Chorlton ece215c181
reject tarball writes with no destinations (#1534)
* reject tarball writes with no destinations

* Update pkg/snapshot/snapshot.go

Co-authored-by: Tejal Desai <tejal29@gmail.com>
2021-01-03 10:13:05 -08:00
Matt Moore 1ad4295462
Update ggcr to pick up estargz and caching option (#1527) 2020-12-21 10:09:21 -08:00
Tejal Desai b04399eeac
add caching copy layers back (#1518)
* add caching copy layers back

* fix test

* lint

* fix test - 2

* Add integration test

* fix lint
2020-12-11 00:25:03 -08:00
Vincent Behar dde98a8e73
feat(warmer): Warmer now supports all registry-related flags (#1499)
which means we can now:
- set up one or more mirrors
- set up registries certificates
- skip TLS verify
- use plain HTTP
using the same set of flags that are defined for the executor
2020-12-10 22:55:43 -08:00
ejose19 2f8d939b3f
fix: CheckPushPermissions not being called when CacheRepo was set (#1471) 2020-10-29 23:46:00 -07:00
ejose19 0ef3a6b525
Fix permissions on cache when --no-push is set (#1445) 2020-10-02 10:11:12 -07:00
Akram Ben Aissi ab768b5d26
Allow DOCKER_CONFIG to be a filename (#1409)
* Allow DOCKER_CONFIG to be a filename

* UnitTest: DockerConfLocation must return a file if it is existent and passed using env, or default if the file is incorrect
2020-09-30 16:45:34 -07:00
Tejal Desai 0c386e3f4a
fix docker-credential-gcr helper being called for multiple registries (#1439)
* fix multiple registryies docker-credential-gcr

* Update pkg/executor/push.go
2020-09-30 16:43:16 -07:00
Tejal Desai 1990cb76e9 change repo string to just string 2020-09-09 09:09:19 -07:00
Jon Johnson c42881410c Add pkg.dev to automagic config file population
Kaniko currently does config file setup for GCR such that pushing to GCR
automagically works. This change does the same for pkg.dev:
https://cloud.google.com/artifact-registry

This also tightens up the hostname check to ensure we don't send
credentials to a registry that happens to contain "gcr.io".
2020-06-23 11:23:07 -07:00
Ben Einaudi 2f6090dcd7 Remove use of DefaultTransport
Using DefaultTransport and manipulating its tls configuration may lead to unexpected behaviour
2020-05-20 11:43:13 +02:00
Tejal Desai da5c420ee9 use a mock 2020-05-19 15:05:46 -07:00
Mitchell Friedman 6978fab45c Add retries to image push.
This uses the default provided retry transport by
go-containerregistry as this originally had no retries
built in.

This is useful to avoid intermittent failures of image
registries when returning a retryable status code.
2020-05-08 14:18:43 +01:00
David Dooling 8bfd370ef9
Provide full path to Docker config file
Add tests.  The tests assume a POSIX file system, but it seems many
other tests assume Linux, so perhaps this is not a problem, or at
least does not add a new problem.

Fixes #1235
2020-05-06 10:02:47 -05:00
David Dooling 0871dfd6ab
Use DOCKER_CONFIG for docker config location
If the DOCKER_CONFIG environment variable is set, use it when
determining if the Docker config file exists.  Fall back to kaniko
default if it the DOCKER_CONFIG environment variable is not set.

Fixes #1228
2020-05-04 16:46:50 -05:00
Sam Stoelinga c56f16b163 Create constant for Docker conf location 2020-03-21 16:45:04 -07:00
Sam Stoelinga 8518b37ca1 Add unit tests for CheckPushPermissions 2020-03-21 16:15:34 -07:00
Sam Stoelinga 66268690b3 Add comments 2020-03-17 09:11:50 -07:00
Sam Stoelinga 8a020010b7 Add ability to use public GCR image
Kaniko by default used to configure the GCR credential helper however
this caused Kaniko to fail when trying to use a base image from a public
GCR image. This patch makes it possible to use public GCR images as base
image when using docker even when you're not authenticated to GCR.

Co-authored-by: Nate Williams <nate.williams@files.com>
2020-03-17 09:09:41 -07:00
Ben Einaudi b73c2c10c8 Allow user to provide registry certificate
Fixes #1100
Fixes #1101
2020-03-08 18:17:50 +01:00
Will Ripley f6aa8f709b Modified error message for writing image with digest file 2019-11-08 12:59:25 -06:00
Will Ripley c8f089fdbb Fixed formatting errors with push.go and push_test.go 2019-10-29 13:09:27 -05:00
Will Ripley a0651436b5 Changed image name to be full image name minus tag. Also added test for new ImageNameDigestFile flag 2019-10-29 12:55:50 -05:00
Will Ripley f38c47daa0 Made changes to --image-name-with-digest-file to support multiple destinations 2019-10-29 10:55:49 -05:00
Will Ripley 4c9a800e12 Added image digest file path 2019-10-21 11:55:55 -05:00
Tejal Desai f206e3f425
Merge branch 'master' into output 2019-10-04 08:43:02 -07:00
Don McCasland ccd99fbeec
Merge pull request #685 from tralexa/master
insecure flag not honored in cache
2019-09-20 13:32:19 -07:00
Tejal Desai e048b87222
Merge pull request #671 from abergmeier/fix_comment
Correct CheckPushPermission comment.
This is a typo fix.
2019-09-17 10:44:54 -07:00
alexa 62acf3ac1d change schema to http when Insecure flag is enabled 2019-09-16 16:35:45 +03:00
chhsia0 11f3b791cd Renamed to `--oci-layout-path` and added a unit test. 2019-08-24 01:28:58 -07:00