-
Notifications
You must be signed in to change notification settings - Fork 2.3k
configure imagePolicyConfig:allowedRegistriesForImport #7197
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
configure imagePolicyConfig:allowedRegistriesForImport #7197
Conversation
@@ -77,6 +77,9 @@ | |||
kube_admission_plugin_config: "{{openshift_master_kube_admission_plugin_config | default(None) }}" # deprecated, merged with admission_plugin_config | |||
oauth_always_show_provider_selection: "{{ openshift_master_oauth_always_show_provider_selection | default(None) }}" | |||
image_policy_config: "{{ openshift_master_image_policy_config | default(None) }}" | |||
image_policy_allowed_registries_for_import: "{{ openshift_master_image_policy_allowed_registries_for_import | default(None) }}" | |||
image_policy_additional_allowed_registries_for_import: "{{ openshift_master_image_policy_additional_allowed_registries_for_import | default(None) }}" | |||
default_image_policy_allowed_registries_for_import: "{{ default_image_policy_allowed_registries_for_import }}" |
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.
Instead of setting the defaults here, is it possible to load them from set_allowed_registries()
? Not sure it's the best way but the current approach is not consistent with anything around.
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.
Resolved. By default, everything is allowed.
b9d4e24
to
7192178
Compare
# Keep in sync with DefaultAllowedRegistriesForImport in | ||
# openshift/origin/blob/master/pkg/cmd/server/apis/config/types.go | ||
default_image_policy_allowed_registries_for_import: | ||
allowedRegistriesForImport: |
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 maybe generated by the openshift
binary and fetched from the library module when needed?
(the binary already generates this on openshift start master --write
, I'm just not sure, how to utilize that here)
5a698a6
to
de67599
Compare
Just realized that there is a lot of variables like:
If the admin overrides any of those to some custom registry without touching Should those prefixes be added to the defaults? Or should we run some sanity check at the beginning? |
/assign @sdodson @jim-minter @bparees FYI |
Some of the extended tests are now failing:
And this looks to be the reason (forbidden translated to 500):
The docker-registry is not configured to use the same dns name as the cluster ( |
/hold |
|
@miminar i'm puzzled by why this change is causing problems. The existing behavior was such that the ansible install didn't set a whitelist, which should have meant we fell back to the hardcoded whitelist, right? And the hardcoded whitelist is the same as the whitelist you've introduced explicilty. |
We don't fall-back to hardcoded whitelist. If the policy whitelist is not configured in the master config file, no whitelist will be used - meaning "allow all". The thing I don't understand right now is why the job ci/openshift-jenkins/gcp launches registry without dns name configured. Which leads to creation of imagestreammappings with dockerImageReference having Similar job for openshift/origin repository has the same parent job https://github.com/openshift/aos-cd-jobs/blob/master/sjb/config/common/test_cases/origin_release_install_gce.yml that does the setup. The origin job properly configures the registry with |
7157c3c
to
cbd3995
Compare
@bparees So the problem is related to your #6913. The image used for testing ( And there is just I'd prefer to set |
i can live with it. |
318cdfc
to
be3157a
Compare
@miminar I do wonder if for existing clusters that do not have an imageimport policy already, we should not be setting this as we could potentially break them if they are using registries that are not in the default whitelist. Also I suspect we don't want to drop this on 3.9 at this point since auto-defining/defaulting the registry whitelist could have some unexpected effects. |
/retest |
Adding a hold as well. /hold Probably need to have a discussion about the point of this now. |
@smarterclayton what sort of discussion? Don't we still want admins to be able to set this value at install time, even if the default behavior is to allow all registries? |
fba6d35
to
0897ec4
Compare
0897ec4
to
0e613a2
Compare
Rebased. /retest |
/retest |
The gcp test succeeded finally. Don't ask me why. |
@smarterclayton No registry whitelist is configured by default which matches origin's latest behaviour. This only allows for whitelist configuration if the admin desires. |
bot, retest this please |
0e613a2
to
8e50a18
Compare
Squashed and removed debug statements. |
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.
Lint fixes needed
if not image_policy_config: | ||
return image_policy_config | ||
|
||
if isinstance(image_policy_config, basestring): |
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.
s/basestring/str/
""" turns a list of wildcard registries to allowedRegistriesForImport json setting """ | ||
return { | ||
"allowedRegistriesForImport": [ | ||
{'domainName': reg} if isinstance(reg, basestring) else reg for reg in registry_list |
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.
s/basestring/str/
vague definition of port defaulting based on insecure flag. Moreover, most | ||
of the registries will be listed without the port and insecure flag. | ||
""" | ||
item = "schema://" + item.lstrip("http://").lstrip("https://") |
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.
Use .replace()
to remove multi character strings.
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.
Good catch. Changed to .split('://',1)[-1]
instead.
Signed-off-by: Michal Minář <[email protected]>
8e50a18
to
c95dc5a
Compare
anything else needed here? |
/lgtm |
bot, retest this please |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: miminar, sdodson The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
bot, retest this please |
@miminar: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Currently the allowedRegistriesForImport are not configured by ansible scripts,
which effectively disables whitelisting. This PR sets the default registry
whitelist and allowes for simple overrides.
Related upstream PR: openshift/origin#17783
Related doc PR: openshift/openshift-docs#7788