phenixblue / imageswap-webhook

Image Swap Mutating Admission Webhook for Kubernetes
Apache License 2.0
154 stars 53 forks source link

how to deal with 1st level repositories? #41

Closed fragolinux closed 3 years ago

fragolinux commented 3 years ago

hi according to harbor docs, in case a repository is 1st level (like for example nginx, debian, ubuntu, etc), they suggest to add "library" before the wanted image... how to deal with this automaGically using imageswap? In maps config i can add a single docker.io line, to point images to my harbor server and project, so i find no way to add 2 lines there, one with "library" and one without... the only thing i could do is alter all images lines adding there the library/ pre-path... thoughts? Thanks in advance

phenixblue commented 3 years ago

I think I have a fix for this, I just need to test it a bit more.

What I'm thinking right now would be something along the lines of this in the maps file:

docker.io:harbor.example.com
docker.io-library:harbor.example.com/library

This would be the output for the library vs. non-library images:

nginx:latest ->harbor.example.com/library/nginx:latest

tmobile/magtape:latest -> harbor.example.com/tmobile/magtape:latest

@fragolinux would something like that work?

fragolinux commented 3 years ago

brilliant, thanks! For now we were adding "library/" to every image missing the 1st part, your way this will be unneeded, thanks!

phenixblue commented 3 years ago

Ok, great. I'll try to get testing wrapped up and a release cut.

phenixblue commented 3 years ago

@fragolinux I just created the v1.4.1 release that includes this enhancement.

Slight change to the previous syntax I posted though:

<registry>/library is the syntax for the map config key.

Example:

docker.io:harbor.example.com
docker.io/library:harbor.example.com/library

Let me know if you have any issues

fragolinux commented 3 years ago

thanks, much appreciated :)

fragolinux commented 3 years ago

the example in the release page still reports the "wip" syntax with dash instead of slash

phenixblue commented 3 years ago

Thanks, copy/paste mistake. Corrected now