-
Notifications
You must be signed in to change notification settings - Fork 73
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
Restrict update automation to certain folders in a repository #100
Comments
Duplicate of #72 |
Not a duplicate of #72, just similar subject matter. #72 is specifically about whether image-automation-controller should honour the This issue approaches filtering files in the git repository from another direction: what do you do if you want to run two or more different specs for automation on the same git repository? #72 doesn't solve this satisfactorily -- you would have to have |
I agree that this is going to be a common use case if Flux v2 users are encouraged to build fleet/multi tenant repos. Right now the Image automation is not usable when you have more than 1 cluster with differing image policy specs and the app deployment manifest (be that a HelmRelease, Deployment, Pod etc) stored in a single repo and then using Kustomize to patch accordingly. For example, I have a single fleet repo that contains apps, infrastructure and clusters folders. Flux is bootstrapped against the folder cluster/. Within that folder are details of what flux should be managing in the cluster, one of those details is a Kustomization object that points to the folder apps/ (this is where the details of any non-infrastructure related apps are held). Within apps I have a base/ folder structure for each app that is available for my clusters. Then within apps/ I source in base/ and patch accordingly, including the HelmRelease and setting the Image policy marker, and finally creating the ImagePolicy I want for that app in that specific cluster. The issue with ImagePolicy and hence this issue being raised, is that when Image policies with differing specs are created in different clusters BUT created with the same image policy name and namespace, the Image Automation logic will scan the whole git repo, find a marker and update it no matter if that marker belongs in a file that the flux for that cluster is meant to monitor. The Flux V2 documentation provides a guide for Image Automation - https://toolkit.fluxcd.io/guides/image-update/ - which implies that clusters can have differing Image policy specs. However, there are no details in the guide in how to implement this. The guide only shows the implementation for the Production CI/CD workflow. Right now it seems the only way to implement this is to make sure the ImagePolicy name is unique in every cluster which is doable but just adds another layer of management that shouldn't be needed. |
The way I currently handle this in a repository where I have multiple overlays corresponding to different environments is by adding a suffix to the I think the best way to tackle this would be through implementing another attribute in the customize fieldmeta marker. Here's a possible design: # automation.yaml
apiVersion: image.toolkit.fluxcd.io/v1alpha1
kind: ImageUpdateAutomation
metadata:
name: default
spec:
...
update:
strategy: Setters
selector: uniqueid # <-- this bit here # kustomization.yaml
images:
- name: app
newName: someorg/someapp
newTag: v1.0.0 # {"$imagepolicy": "flux-system:default:tag", "selector": "uniqueid"} I'm not sure it's possible to implement it this way. |
Thanks @relu. I have done the same 0 my suffix is the cluster name. |
I'm in the process of migrating from flux v1 to v2 with a multi-cluster/multi-environment setup and this has caused a giant headache. I had expected the I can imagine many other developers running into this same unexpected behavior, and I don't believe this is mentioned in the docs. |
I would think that you could get around this by telling the But, that also seems to not be true. I tried updating the main I would think that if flux is only tarring up the folders as specified in the |
Hi there,
I can see there was an "path" field in the spec which was discussed in #24 and removed with pull request #64 due to missing use-cases. I might have a possible use-case. The flux2 documentation states how to setup up multiple clusters/stages in different folders of the same repository. Like the folder "dev" is deployed into the dev-cluster, the folder "prod" to the prod-cluster an so on. But this can cause conflicts. If different clusters have ImagePolicies with the same name, but different spec, the automation-controller of the dev-cluster will not only adjust the version-tags in the "dev" folder, but also in the folders of the other stages. Possible solutions would be:
To implement the "path" field would be a big improvement in this case.
Best regards
Philipp
The text was updated successfully, but these errors were encountered: