-
Notifications
You must be signed in to change notification settings - Fork 278
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
Multiple registries.yaml rewrites order is not preserved in containerd config.toml #3227
Comments
This is kind of a deficiency in the way we implemented rewrites. We probably should have made the rewrites a list, not a map. Since it’s a The workaround is to modify the |
Reopening as an enhancement request. This would require changes to the registries struct, as well as to the containerd patch we’re carrying. The Rancher UI would probably also need to be modified to use the new field, and anyone who wanted to take advantage of it on their own would need to migrate their config. The registries bit would look something like: quay.io:
endpoint:
- "https://harbor.internal.com:5000/"
rewrites:
- source: "strimzi/(.*)"
replacement: "registry1.dso.mil/ironbank/opensource/strimzi/$1"
- source: "jetstack/(.*)"
replacement "registry1.dso.mil/ironbank/jetstack/$1"
- source: "(.*)"
replacement: "quay.io/$1" I’m not sure what the toml side would look like; I’ll have to brush up on whether or not subsections are returned in any sort of order or not, but probably something like: [plugins.cri.registry.mirrors."quay.io"]
endpoint = ["https://harbor.internal.com:5000/"]
[plugins.cri.registry.mirrors."quay.io".rewrites.0]
source = "strimzi/(.*)"
replacement = "registry1.dso.mil/ironbank/opensource/strimzi/$1"
[plugins.cri.registry.mirrors."quay.io".rewrites.1]
source = "jetstack/(.*)"
replacement = "registry1.dso.mil/ironbank/jetstack/$1"
[plugins.cri.registry.mirrors."quay.io".rewrites.2]
source = "(.*)"
replacement = "quay.io/$1" |
Although the ask here isn't exactly the same, the proper way to do this is probably what's discussed at k3s-io/k3s#5568 |
I also got hit by this with K3s.
This works fine for the However apparently you need to have a catchall rewrite |
Yes, you'd need to ensure that the wildcard doesn't match the k3s-upgrade image. It is unfortunate but probably won't be fixed until we switch to the new containerd config directory schema. |
I was wrong saying my above example works. The regexp is only for image name and the tag part is not included. So instead of:
I could also use:
Reading the containerd documentation I assume it is not possible to do a rewrite based on image version. It is only possible by image name? |
correct. You're rewriting the repository portion of the image spec. Not the registry, and not the tag. |
This comment was marked as off-topic.
This comment was marked as off-topic.
How is it now ? |
Same. Not generally a huge issue though, you just have to be strategic with your regexes. |
I try to use regexes like this docker.io:
endpoint:
- "https://my-registry.me"
rewrite:
"repo1/(.*)": "private/$1"
"repo2/(.*)": "private/$1"
"^((?!repo1|repo2).+)/(.*)": "public/$1/$2" then k3s restart failed:
|
Check the golang docs on regexes to see what syntax is supported. |
Environmental Info:
RKE2 Version: v1.21, v1.22, v1.23
Node(s) CPU architecture, OS, and Version:
CentOS 7.9.2009 x86_64
Cluster Configuration:
1 Node Server/Agent combo
Describe the bug:
When using multiple rewrites in registries.yaml, the order of those rewrites are not preserved in the containerd configuration. This leads to RKE2 pulling from the wrong places.
Steps To Reproduce:
Expected behavior:
It's expected that the order of rewrites is honored and preserved.
Actual behavior:
The order of rewrites appears to be put in via alphabetical order.
Additional context / logs:
The text was updated successfully, but these errors were encountered: