-
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 flag to remap registries for any registry mirror #2935
Conversation
The purpose of this PR is to add an option to remap registries, a kind of generalized `--registry-mirror`. This is helpful for air-gapped environments and/or when local registry mirrors are available (not limited to docker.io). This allows user to reference any images without having to change their location. It also permit to separate infra related configuration (the mirrors) from CI/CD pipeline definition by using an environment variable for example (the reason behind the early return if flag provided but empty). Therefore you can have a pipeline calling kaniko with `--registry-map=$REGISTRY_MAP` and have the `REGISTRY_MAP` populated via the runner's env by another team, and the absence of env wouldn't trigger a failure, it makes the pipeline env independent. I've also considered the option of environment variables directly but it doesn't seems to be in kaniko's philosophy. This makes quite some duplicated code :/ One option to keep the mirror flag and behavior would be to use only one codebase and convert `--registry-mirror=VALUE` to `--registry-map=index.docker.io=VALUE` internally. Suggestions welcome!
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Still open to suggestions ;-) |
I've finally decided to replace registry mirror with map logic and allow use of environment variable as |
Related issue #2990 |
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.
Appreciate your patience here @babs. Thanks for the PR, LGTM
Np, happy to see it merged. |
Description
The purpose of this PR is to add an option to remap registries, a kind of generalized
--registry-mirror
. This is helpful for air-gapped environments and/or when local registry mirrors are available (not limited to docker.io). This allows user to reference any images without having to change their location. It also permit to separate infra related configuration (the mirrors) from CI/CD pipeline definition by using an environment variable for example (the reason behind the early return if flag provided but empty). Therefore you can have a pipeline calling kaniko with--registry-map=$REGISTRY_MAP
and have theREGISTRY_MAP
populated via the runner's env by another team, and the absence of env wouldn't trigger a failure, it makes the pipeline env independent.I've also considered the option of environment variables directly but it doesn't seems to be in kaniko's philosophy.(see update 1)This makes quite some duplicated code :/ One option to keep the mirror flag and behavior would be to use only one codebase and convert(see update 1)--registry-mirror=VALUE
to--registry-map=index.docker.io=VALUE
internally.Suggestions welcome!
[UPDATE 1]
As there is a
KANIKO_REGISTRY_MIRROR
, I addedKANIKO_REGISTRY_MAP
.I've also replaced the mirror logic with map, keeping the original behavior.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
Reviewer Notes
Release Notes