Skip to content
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

Mutation to replace image registry #2381

Open
ritazh opened this issue Nov 2, 2022 · 12 comments
Open

Mutation to replace image registry #2381

ritazh opened this issue Nov 2, 2022 · 12 comments
Assignees
Labels

Comments

@ritazh
Copy link
Member

ritazh commented Nov 2, 2022

    Another scenario  for a more dynamic mutation is replacing image registry per cluster env. 

For instance, you define kube manifests once, let’s say it uses image grafana/grafana .

Based on the kube cluster it deploys to, mutation webhook can change/prepend the image registry to use private one.

Alternatively user would deploy custom mutation webhook or worst case, clobber the deployment manifests for each env.

This is highly desirable and kyverno policy engine has lot of maturity on it.

Originally posted by @tahirraza in #1134 (comment)

@tahirraza
Copy link

Thank you for creating the issue. I'd be happy to do jump in as needed.

@tahirraza
Copy link

@davis-haba
Copy link
Contributor

A change to support this is in flight: #2429

@tahirraza
Copy link

Above PR seems merged. What's ETA for this in the future release ?

@ctml91
Copy link

ctml91 commented Apr 4, 2023

Is it possible to use AssignImage, to replace the registry using a condition? For example, I want to replace any container image using docker.io to internal-registry.io. With the current implementation, my understanding it's all or nothing so any pod & container that is matched would get replaced, so it is not possible to set this type of condition? I do not want to replace registries other than docker.io, and do not want to define a hundred AssignImage instances to select specific containers/pods.

It would be nice to have some condition tests, similar to Assigns pathTests except they would need to be tests on the image registry, repo, or tag.

@maxsmythe
Copy link
Contributor

Testing the value-to-be-modified has safety implications WRT convergence, risking turning mutation into a Turing machine:

https://github.com/orgs/open-policy-agent/discussions/15

I agree that there is a usability limitation here, though.

One thought would be to allow filtering (or other tests) on the container name, which would be immutable. I'm not sure container name is always a good proxy/sorting function for which images need re-writing, but curious if it would map on to your use case?

Kubernetes is also looking at hosted mutation (similar to the CEL KEP for hosted validation). I'm curious to see what their conclusions are before investing too deeply into mutations, as that has the potential to significantly disrupt the use cases/value proposition of webhook-based mutation.

@ritazh
Copy link
Member Author

ritazh commented Apr 5, 2023

One thought would be to allow filtering (or other tests) on the container name, which would be immutable.

Would this be a new field or reuse pathTests?

@maxsmythe
Copy link
Contributor

An extension of the location spec. Something like spec.containers[name:~^regexPrefix.*].image (not saying exactly that syntax)

@sozercan
Copy link
Member

sozercan commented Apr 5, 2023

@davis-haba are we okay to close this with #2429?

@ctml91
Copy link

ctml91 commented Apr 5, 2023

I'm not sure container name is always a good proxy/sorting function for which images need re-writing, but curious if it would map on to your use case?

Unfortunately it would really only work for me based on the original image registry. As new workloads get deployed I'd have to keep creating new instances of AssignImage, I would end up with about 300 of these.

Good to know about the hosted mutation, thank you. if you know of any area it's actively being discussed I'd love to follow along.

@maxsmythe
Copy link
Contributor

Let me ask what the status of the discussion is and where/how to engage.

@maxsmythe
Copy link
Contributor

It sounds like the most likely channel is sig-api-machinery's google group:

https://groups.google.com/g/kubernetes-sig-api-machinery

There's some early thought being put into the shape of things and to better understand the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants