fluxcd / image-automation-controller

GitOps Toolkit controller that patches container image tags in Git
https://fluxcd.io
Apache License 2.0
155 stars 67 forks source link

Add support to limit applied policies in automation by specifying a selector #619

Closed Nitive closed 3 months ago

Nitive commented 6 months ago

Add support for policy selector in ImageUpdateAutomation response

Selector can be specified the same way as Deployment.spec.selector (See kubectl explain Deployment.spec.selector for details)

Example:

apiVersion: image.fluxcd.io/v1alpha1
kind: ImageUpdateAutomation
metadata:
  name: update-teleport
spec:
  policySelector:
    matchLabels:
      app.kubernetes.io/component: teleport
      app.kubernetes.io/instance: teleport
  ...

This allowes to have more flexible image updates, for example, we can batch updates of different components to separate branches. This was previously discussed in #499 and fluxcd/flux2#107

verdel commented 4 months ago

@stefanprodan, if you have the time, I would ask you to review this PR.

stefanprodan commented 4 months ago

We discussed this proposal at the Flux dev meeting, we decided to include this in the upcoming Flux minor release scheduled for end of April. @darkowlzz will ask you at some point to rebase this on a diffrent branch. Thanks for your patience.

Nitive commented 4 months ago

@stefanprodan thanks!

darkowlzz commented 3 months ago

Hey @Nitive , as mentioned above, the refactored image-automation-controller code is at https://github.com/fluxcd/image-automation-controller/pull/647 . It's not fully ready yet but the code where you can add the policy selector and tests associated with it are pretty much ready as of today. You should be able to modify the getPolicies() function to accept the selector and use it in the list call. And there's Test_getPolicies() which you can modify and add tests for it. Once done, you can create a PR against the refactor branch. In case you're busy at the moment, please let me know. I can adapt the code in this PR to the new branch myself. We are hoping to release this in April. So please let us know if you'd be able to work on it before then.

Nitive commented 3 months ago

Hey @darkowlzz, I will do it tomorrow

Nitive commented 3 months ago

@darkowlzz, it's done. Can you approve workflows please so tests can run?

Nitive commented 3 months ago

@darkowlzz, thanks for the detailed feedback! I've applied the changes you suggested

Nitive commented 3 months ago

I'll update the documentation shortly (update: done)

Nitive commented 3 months ago

@darkowlzz, fixed