-
Notifications
You must be signed in to change notification settings - Fork 3.8k
mirror repository rewrites #5171
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
Conversation
|
Hi @dweomer. Thanks for your PR. I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Containerd folks: this is something of a magic trick / hack that we will likely be carrying a patch for in the k3s-io/containerd fork specifically for RKE2 and I wanted to at least share with upstream. I am open to alternative methods of achieving the desired functionality. Additional caveat: only works for images pulled via CRI. |
|
Build succeeded.
|
|
Cool - love this PR!! Do you think this can be used or enhanced in a way that we can also rewrite based on the source namespace/path? I.e. rewrite
AND at the same time (source is only different in namespace but on same source registry)
|
|
@Martin-Weiss these use cases are supported as the rewrite rules are regular expressions for matching/replacing anything after the registry root path for actual resources (typically /v2). |
Support CRI configuration to allow for request-time rewrite rules
applicable only to the repository portion of resource paths when pulling
images. Because the rewrites are applied at request time, images
themselves will not be "rewritten" -- images as stored by CRI (and the
underlying containerd facility) will continue to present as normal.
As an example, if you use the following config for your containerd:
```toml
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://registry-1.docker.io/v2"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io".rewrite]
"^library/(.*)" = "my-org/$1"
```
And then subsequently invoke `crictl pull alpine:3.13` it will pull
content from `docker.io/my-org/alpine:3.13` but still show up as
`docker.io/library/alpine:3.13` in the `crictl images` listing.
Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
f388e33 to
dee7dfe
Compare
|
Build succeeded.
|
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd/containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd/containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd/containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd/containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
|
This feature feels to me like it stretches the scope of the containerd project, as it's a bit of higher-level feature. Since the CRI plugin is now a core part of containerd, I think it makes sense for the CRI plugin to stay as close to just implementing CRI as possible rather than adding additional non-standard features.
I have two ideas here that might be alternatives:
|
|
Trying to give some additional thoughts - please forgive me if these are invalid because I am not deep enough into the details..
One challenge is that we need the "rewrite" before k8s is up and running at all - so it must be "below". So I am not sure if this makes sense on a higher level that is not yet available when we have to bootstrap / load initial images and containers into containerd.
Basically the "registry mirror" feature is "just" missing functionality we need in on premise deployments where we just have one central registry with namespaces and where we have to map "external registry/namespace/image to an internal registry/other namespace". |
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
|
@mikebrow do we still think this can get accepted? |
|
For reference cri-o provides the equivalent logic in their container runtime |
mikebrow
left a 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.
this would need some edits to the .md over here:
https://github.com/containerd/containerd/blob/main/docs/cri/registry.md#configure-registry-endpoint
note that the older mirrors mechanism has been deprecated:
https://github.com/containerd/containerd/blame/main/docs/cri/config.md#L293-L294
see:
https://github.com/containerd/containerd/blob/main/docs/hosts.md
we'll need to consider if/how to add rewrites to the new hosts model...
|
@dmcgowan heads up... let's discuss |
Partial adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Remainder of the adaptation of containerd#5171 to 1.4.x Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
|
Wonder if this PR is still valid, because I see it's remained open w/o any update quite long time. I'm having the same problem where I need to map the image into a different namespace. |
PR would need to be ported to the hosts model .. |
|
Thanks @mikebrow ! Do you know when this will be done? |
no I don't |
|
Hadn't checked in on this one in a while, folks, my apologies. I should have the time next week to incorporate requested changes and any necessary contortions to accommodate the newer config model. |
So, 14 months later, I like this idea! @samuelkarp has there been any work on such an effort you could point me to? (I am looking to dial into this project once again but I haven't done a full review of what I have "missed". Any pointers appreciated!) |
I'm not aware of any right now, but I've also been somewhat disconnected while between employers. |
|
So, apologies again, after avoiding the 'rona for over 2 years it has overrun my home. Will be looking to get this refactor off my plate as soon as I am able. |
|
I've decided to not work on this. If you need this functionality it is carried on the k3s fork at https://github.com/k3s-io/containerd/tree/k3s-release/1.5 |
Some pointers on getting the k3s fork of containerd:
|
golimix
left a 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.
good idea
Support CRI configuration to allow for request-time rewrite rules
applicable only to the repository portion of resource paths when pulling
images. Because the rewrites are applied at request time, images
themselves will not be "rewritten" -- images as stored by CRI (and the
underlying containerd facility) will continue to present as normal.
As an example, if you use the following config for your containerd:
And then subsequently invoke
crictl pull alpine:3.13it will pullcontent from
docker.io/my-org/alpine:3.13but still show up asdocker.io/library/alpine:3.13in thecrictl imageslisting.Signed-off-by: Jacob Blain Christen jacob@rancher.com