-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
BZ#1928021: Restricting container registries in Configuring image settings #34585
Conversation
NOTE TO SELF |
✔️ Deploy Preview for osdocs ready! 🔨 Explore the source changes: ae9a147 🔍 Inspect the deploy log: https://app.netlify.com/sites/osdocs/deploys/60f8375d09d7e10007073d5a 😎 Browse the preview: https://deploy-preview-34585--osdocs.netlify.app |
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.
There is a minor typo below.
Other than that, I am missing a section that describes that the following also works:
Instead of just specifying a registry (such as quay.io
), it is also possible to limit projects within that registry:
spec:
registrySources:
allowedRegistries:
- quay.io/openshift-release-dev
The above configuration will only allow images being pulled from quay.io/openshift-release-dev
and for example will block images being pulled frrom quay.io/simonkrenger
.
That should also be reflected in the documentation I believe
@simonkrenger Simon -- In the note below the example, I have When using the I added an repo with a registry to the example:
I believe the initial request was to explicitly add the entire Thanks for your comment! |
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.
@simonkrenger Simon --
In the note below the example, I have When using the
allowedRegistries
,blockedRegistries
, orinsecureRegistries
parameter, you can specify an individual repository within a registry..
…- reg1.io/myrepo/myapp:latest
NAK.
That would be a useful feature, but right now it only happens to work but is not designed to.
The API in https://github.com/openshift/api/blob/02b64ca27d54dafe24b8740e45662f45bd3a332e/config/v1/types_image.go#L110-L114 is not documented that way, there are AFAIK no regression tests, the relevant MCO code talks about registries and not repos. Unless all of that changes, the behavior may change any time, whether due to unrelated feature work or because someone decides to add stricter validation for allowedRegistries.
@mtrmac This change came from https://issues.redhat.com/browse/OCPNODE-461 starting in 4.8. If you think it doesn't work in this way, can you please file a docs BZ against 4.8 and assign it to me. I would be happy to look into it. It is out-of-scope for this PR, as removing things from the docs requires a (sometimes) lengthy approval process. |
I’m not saying it doesn’t work, I’m saying there’s nothing established to ensure it will continue to work. *sigh* If this is considered already publicly documented enough that there might be users’ deployments, I guess we can just roll with it and deal with regressions as they come; there’s no putting the genie back into the bottle. |
@mtrmac Documenting this was the root cause for https://bugzilla.redhat.com/show_bug.cgi?id=1928021. Customers are concerned when they need to add So we created https://bugzilla.redhat.com/show_bug.cgi?id=1928021 to document that for example If we do not want to document this (fine by me), we should at least provide some other mechanism to make sure customers can somehow limit what can be pulled from |
I’m not objecting to the idea of the feature at all; we would not provide “some other mechanism”, we would provide exactly this mechanism, but with code documentation and testing infrastructure that doesn’t exist yet. We put the cart before the horse. |
Understood, thanks for the clarification |
@mtrmac @simonkrenger I was asked in a BZ to add a note to the Blocked Registries topic that states To prevent pod failure, do not add the registry.redhat.io and quay.io registries to the blockedRegistries list, as they are required by payload images within your environment. To be safe, I added another note to the Allowed Registries topic to make sure When the My concern now, if we provide an example of a specific quay.io repo ( |
That’s a good question, but not one I can answer. |
@mtrmac I reviewed the QE test case and it appears you might be correct. It appears that he used a dummy repo/registry to verify that the MCO updated the search registry lists on the nodes (which I also did, not having access to live repos/registries to test), and not whether the change has an effect on the node's ability to pull just from that registry. Is this your understanding? |
That looks like a test case for |
@simonkrenger Can I move this PR forward to address your core concern that the ability to add specific repos to the allow-lists? I can track @mtrmac concerns and my questions about specific quay.io registries in separate issues, as needed. |
@mburke5678 Sure. I also updated RFE-1011 to share my thoughts. |
@xltian - any chance that this can be tested completely for us to document it? |
(To clarify, I meant API documentation and automated unit tests; there well might have been some manual end-to-end testing I’m not aware of.) |
@sunilcio Can you please take a look at the changes? I moved some information that was in the individual allowedRegistries and blockedRegistries topic into the Configuring image settings topic, which is aslo used in the Post-installation Preparing for Users topic. No new text. Feel free to weigh in on any of the other concerns in this PR: |
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.
Couple of minor things, but this is looking good!
@@ -52,11 +53,15 @@ status: | |||
<1> `Image`: Holds cluster-wide information about how to handle images. The canonical, and only valid name is `cluster`. | |||
<2> `allowedRegistriesForImport`: Limits the container image registries from which normal users may import images. Set this list to the registries that you trust to contain valid images, and that you want applications to be able to import from. Users with permission to create images or `ImageStreamMappings` from the API are not affected by this policy. Typically only cluster administrators have the appropriate permissions. | |||
<3> `additionalTrustedCA`: A reference to a config map containing additional certificate authorities (CA) that are trusted during image stream import, pod image pull, `openshift-image-registry` pullthrough, and builds. The namespace for this config map is `openshift-config`. The format of the config map is to use the registry hostname as the key, and the PEM certificate as the value, for each additional registry CA to trust. | |||
<4> `registrySources`: Contains configuration that determines how the container runtime should treat individual registries when accessing images for builds and pods. For instance, whether or not to allow insecure access. It does not contain configuration for the internal cluster registry. This example lists `allowedRegistries`, which defines the registries that are allowed to be used. One of the registries listed is insecure. | |||
<4> `registrySources`: Contains configuration that determines whether the container runtime allows or blocks individual registries when accessing images for builds and pods. Either the `allowedRegistries` parameter or the `blockedRegistries` parameter can be set, but not both. You can also define whether or not to allow access to insecure registries or registries that allow registries that use image short names. This example uses the `allowedRegistries` parameter, which defines the registries that are allowed to be used. The insecure registry `insecure.com` is also allowed. The `registrySources` paramter does not contain configuration for the internal cluster registry. |
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.
<4> `registrySources`: Contains configuration that determines whether the container runtime allows or blocks individual registries when accessing images for builds and pods. Either the `allowedRegistries` parameter or the `blockedRegistries` parameter can be set, but not both. You can also define whether or not to allow access to insecure registries or registries that allow registries that use image short names. This example uses the `allowedRegistries` parameter, which defines the registries that are allowed to be used. The insecure registry `insecure.com` is also allowed. The `registrySources` paramter does not contain configuration for the internal cluster registry. | |
<4> `registrySources`: Contains configuration that determines whether the container runtime allows or blocks individual registries when accessing images for builds and pods. You can set either the `allowedRegistries` parameter or the `blockedRegistries` parameter but not both. You can also define whether or not to allow access to insecure registries or registries that allow registries that use image short names. This example uses the `allowedRegistries` parameter, which defines the registries that are allowed to be used. The insecure registry `insecure.com` is also allowed. The `registrySources` parameter does not contain configuration for the internal cluster registry. |
Also, is "registries that allow registries that use image short names" right? I can't tell if the repetition is intentional.
+ | ||
[NOTE] | ||
==== | ||
When the `allowedRegistries` parameter is defined, all registries, including the registry.redhat.io and quay.io registries and the default internal image registry, are blocked unless explicitly listed. If you use the parameter, to prevent pod failure, you must add the `registry.redhat.io` and `quay.io` registries and the `internalRegistryHostname` to the `allowedRegistries` list, as they are required by payload images within your environment. Do not add the `registry.redhat.io` and `quay.io` registries to the `blockedRegistries` 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.
When the `allowedRegistries` parameter is defined, all registries, including the registry.redhat.io and quay.io registries and the default internal image registry, are blocked unless explicitly listed. If you use the parameter, to prevent pod failure, you must add the `registry.redhat.io` and `quay.io` registries and the `internalRegistryHostname` to the `allowedRegistries` list, as they are required by payload images within your environment. Do not add the `registry.redhat.io` and `quay.io` registries to the `blockedRegistries` list. | |
When the `allowedRegistries` parameter is defined, all registries, including the registry.redhat.io and quay.io registries and the default internal image registry, are blocked unless explicitly listed. If you use the parameter, to prevent pod failure, you must add the `registry.redhat.io` and `quay.io` registries and the `internalRegistryHostname` to the `allowedRegistries` list, because they are required by payload images within your environment. Do not add the `registry.redhat.io` and `quay.io` registries to the `blockedRegistries` list. |
Double-check the use of backticks in this note. I'd probably put registry.redhat.io and quay.io in bacticks because they're specific registries.
When using the `allowedRegistries`, `blockedRegistries`, or `insecureRegistries` parameter, you can specify an individual repository within a registry. For example: `reg1.io/myrepo/myapp:latest`. | ||
|
||
Insecure external registries should be avoided to reduce possible security risks. |
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.
! should verb
Whenever possible, rewrite in a more direct way. Do not use "should" to refer to an action that must be performed.
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.
@kalexand-rh Here should does not mean must, it is a recommendation, not requirement. I rewrote, also removing the passive:
Avoid using insecure external registries to reduce possible security risks.
include::modules/images-configuration-cas.adoc[leveloffset=+3] | ||
|
||
include::modules/images-configuration-insecure.adoc[leveloffset=+3] | ||
For more information on the allowed, blocked, and insecure registry parameters, see xref:../openshift_images/image-configuration.adoc#images-configuration-file_image-configuration[Configuring image registry settings]. |
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.
Because this assembly heavily favors includes over xrefs, I suggest considering using an include instead. (I assume that you're happy with the modules that you're removing.)
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.
@kalexand-rh I would need to add 2 includes, for a total of 4, to get all of the topics in the linked topic. That seemed a bit excessive, as the topic is already quite long. Going from what I have here, not using the includes for the image-configuration
docs to adding them, adds ~15 page downs to the file on my laptop (~55 to ~70).
That one section should give enough info for folks to get started. The insecure and short name are optional. Perhaps @ahardin-rh can weigh in?
@mburke5678 @mtrmac I updated test case with correct steps for namespaces/repositories and tested again. Also added comment in OCPNODE-461 . The feature is working as expected. For API documentation and automated unit tests part mentioned in comment , I guess @QiWang19 can help answer? |
/lgtm |
I will look into how MCO works with the AllowedRegistries later. |
/cherrypick enterprise-4.8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1928021
When I updated and improved the topics on allowed, blocked, and insecure registries recently in the Image configuration resources assembly,I didn't bring the changes to the post-install Preparing for users module well enough.
With this PR I added some of the new information that I had added to Image configuration to Preparing for users and put a link to Image configuration resources.
Direct preview link: https://deploy-preview-34585--osdocs.netlify.app/openshift-enterprise/latest/post_installation_configuration/preparing-for-users.html#images-configuration-file_post-install-preparing-for-users