You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why ImagePolicy immediately trigger IA to commit update? #313
For what there are .Interval in IA CRD? I want to implement more batched update. In my logic ImageRepository (IR) scanning with interval and provides image list, ImagePolicy (IP) selects, then IA with interval push all changes, but my setup where IR.Interval eq. 1m and IA.Interval eq. 15m pushes update immediately after the related IP selects new image even if IA already starts ~1 minute ago.
Reacted by Mateusz Wużyński, Jamie Spittal and fhoekstra
changed the title [-]Why ImagePolicy immediately trigger IA to commit update[/-][+]Why ImagePolicy immediately trigger IA to commit update?[/+]on Feb 10, 2022
You can bundle multiple updates by telling IAC to create a branch. Then it's in your power to decide when to merge the changes to the branch synced by Flux.
Well, that kind of defeats the purpose of having it in a first place if I have to manually check PR and merge it. Any chance we can get a feature request for batch update? On my setup, I noticed that it sometimes commits few images instead of one. Why is that?
IAC reacts to events sent by the ImageRepository objects, if by chance the scanning happens in parallel for multiple repos and all of them have updates, those will be included in the same commit.
I have 7 ImageRepository objects defined, each of them having interval set to 1m. My IAC have interval set to 10m. So that means IAC is ignoring it's interval property?
If I had ImageRepository interval set to 1h with IAC set to 10m would IAC trigger repository scanning every 10 minutes?
And will be nice if IA updates repository based on IP, not IP triggers IA. I don't see any advantages in the current approach, you can describe it, it's interesting, but in my situation, for big, unicorn chart, where 20+ policies relate single automation and CI performs parallel builds for many apps, i see how single update iteration stretch into multiply commits/updates and it's overlap.
I already inderstand that it's by design and you can close issue if everything works as it should. Sorry for my English, i hope my main minds are clean!
set bigger intervals in ImageRepository objects. I set it to 720h
create flux webhook to trigger all ImageRepository reconciliation, this webhook is pinged by my CI, after all images have been built. This is causing all image updates to be in one commit
additionally, I put my helm release values to config map. It causes every change to helm release be deployed during interval reconcilation
ConfigMap and Secret values overrides. Changes to these do not trigger an immediate reconciliation, but will be handled upon the next reconciliation. This is to avoid a large number of upgrades occurring when multiple resources are updated.
In general it very complicated in my case (builds come not from single repo), but i did not know about configMap behav., thanks for this! Okay, it will be 5 commits in 3 minutes, but it will be single reconcilation every 5 minutes for example. It's really what i want!
additionally, I put my helm release values to config map. It causes every change to help release be deployed during interval reconcilation
Via kustomize configmap generator ofk? Image Update Automation wants YAML structure to change images.
@lictw No, this is a clever workaround. Using the kustomize configmap generator strategy ensures that every change to the configmap gets applied right away, because the configmap has a name with hash suffix, and the hash changes every time the content changes (and so does the HelmRelease, because configmap generator is shown with nameReference.fieldSpecs configuration in the example that you referenced.)
This approach works for the intended purpose as @Wuzyn describes precisely because it does not take any hash or update right away. It must wait around for the interval, and not reconcile immediately on every change. HelmRelease does not have any subscription to the ConfigMap that it lists in valuesFrom, it only knows to update whenever its spec changes, when it is notified by a source that has changed, or when it is reconciled after any input changed (either manually reconciled or due to the interval expiration).
@kingdonb I didn't fully understand your idea.. Cause of IUA wants to deal with yaml files, I didn't see way other than configmapGenerator, so I did it with generatorOption.disableNameSuffixHash and it's work fine.
About every change to the configmap gets applied right away, because the configmap has a name with hash suffix:
How? I can't apply this schema, my kustomize don't apply hash at configmap's name referenced in HelmRelease, I tried to achieve this in other task, what's wrong?
In this case, spec/valuesFrom/name is the path in the HelmRelease which Kustomize searches for values of secret (or configmap) names that are matching the secret (or cm) generator, so that Kustomize can substitute the generated name with the hash suffix there. That's what it looks like you're missing, you need to add:
configurations:
- kustomizeconfig.yaml
or whatever name you prefer for this Kustomize config file, and then Kustomize will make the substitutions whenever the secret/cm has changed in the generator.
Hey, I understand that ImageAutomationController reacting to ImageRepository and the subsequent ImagePolicy updates is desired behaviour but I wish there was a 'window' to capture changes.
For example we have 4 ImageRepository objects with corresponding ImagePolicy and they update ~10 seconds of each other. Sometimes we get lucky and a single ImageAutomationController commit will contain multiple image updates, but often we get a separate commit per ImagePolicy update. This ends up being noise in our commit history, and is something I wish we had more control over.
A solution could be that on the ImageAutomationController.spec there could exist a window parameter that will wait a certain amount of time after a reconciliation was triggered to 'collect' any more ImagePolicy updates that might be coming before committing to the repo.
@Spittal One way to mitigate having multiple commits in your history is to let IAC push to a specific branch and automatically create a PR (or MR in GitLab terms) from that branch. Then you can squash the commits before merging.
A challenge to implement a wait is that maybe the images usually arrive within 10s of each other, but maybe it's sometimes a bit longer. How do you decide the timeout? The longer you make it, the longer people perceive that it takes for IUA to do its job.
Pull requests that get merged at a point in time are a good solution for this. You wait until you see all the necessary changes, then merge it. With squash merges you won't necessarily even be able to tell they weren't one commit.
It could still be a nice feature but it sounds like a hack. If another image comes in, do you reset the timeout or keep counting? If people set the timeout too long and have too many imageupdateautomations, it will hang the controller. They will have to increase the concurrency and things will generally take longer.
What you're looking for is probably better served by a tool like Kargo (Christian Hernandez presented this at Bug Scrub last week and the week before!)
It could still be a nice feature, but it sounds like a hack.
Yeah, it certainly has that feeling. We spoke internally at length about this because the only "downside" we identified with the current Flux behavior is that it's creating multiple commits, which feels unintuitive. However, when our images inevitably diverge in the speed of building, then an IAC window feature becomes a moving target like you described above.
Furthermore, another way to look at this is that Flux is attempting to update as fast as possible, and that's something we actually want in our deployments.
I think something that would've been really helpful for us to come to that conclusion earlier would be a mention in all interval docs that describes this.
Yes, any change event triggers a reconciliation outside the interval, no matter the Flux object.
If that's something that you'd be interested in I can take a swing at a PR for this doc change BTW.
Thanks for the quick replies!
P.S. Thanks for the Kargo recommendation. We have seen this floating around but haven't dug into it. Looking forward to taking a look!
We have the same situation and desire as Spittal describes above: we reconcile new images in staging via ImageUpdateAutomation, and many images are built/pushed within seconds of each other, cluttering up our git log with image update commits.
We don't mind waiting a few minutes when a new image is pushed, to have a cleaner commit log.
Furthermore, another way to look at this is that Flux is attempting to update as fast as possible, and that's something we actually want in our deployments.
For us, it's a trade-off in commit log spam in our monorepo vs speed. That's why batching should be opt-in.
I envision adding a spec.batching field with spec.batching.enabled, spec.batching.window and any future additions (batching strategy?) could go under spec.batching too if desired? Alternatively, just a spec.batchingWindow that is null by default.
If another image comes in, do you reset the timeout or keep counting? If people set the timeout too long and have too many imageupdateautomations, it will hang the controller. They will have to increase the concurrency and things will generally take longer.
Thanks for raising this! I see 3 possible ways to do batching:
reset on new pushes: bad, could hang indefinitely
keep counting: requires a stateful component (status field?) to keep track of when the window started. Introduces significant complexity
throttling: this seems like the easiest way to implement: 2 subsequent updates will still cause 2 commits, but if you have significantly more than 2 imagerepositories, this will limit the git log spam by throttling. Furthermore, it may not require any additional stateful component: we can just throttle based on lastPushTime.
the third way seems sensible, if this is going to be implemented at all, as this is clearly not a very hot topic (it's been quiet on this issue for 2 years), and that way introduces the least complexity and maintenance burden to the project.
Would you be open to further discussion or a PR for this?
Thanks for your pointer @matheuscscp : ResourceSets are not just useful for time-based automation, but also simply keeping things in sync with an OCI registry without requiring commits to the GitOps repo.
We have set up something like the following, where we:
Generate a FluxCD Kustomization with an images: block from a generic ResourceSet (essentially a template)
Use a ResourceSetInputProvider for each app, which points to a specific image and tag
This ensures each app is continuously updated with a new digest as new images get pushed to that tag, without anything getting automatically committed to Git by Flux.
Of course, we could also add a cron to the ResourceSet to limit when or how often it updates, but we find we just wanted to reduce the number of automated commits in our Git log, not actually slow down the sync.
Activity
[-]Why ImagePolicy immediately trigger IA to commit update[/-][+]Why ImagePolicy immediately trigger IA to commit update?[/+]Wuzyn commentedon Feb 18, 2022
I have the same problem and it's causing my helm upgrades to overlap, which is obviously causing problems :/
stefanprodan commentedon Feb 18, 2022
You can bundle multiple updates by telling IAC to create a branch. Then it's in your power to decide when to merge the changes to the branch synced by Flux.
Docs here: https://fluxcd.io/docs/guides/image-update/#push-updates-to-a-different-branch
Wuzyn commentedon Feb 18, 2022
Well, that kind of defeats the purpose of having it in a first place if I have to manually check PR and merge it. Any chance we can get a feature request for batch update? On my setup, I noticed that it sometimes commits few images instead of one. Why is that?

stefanprodan commentedon Feb 18, 2022
IAC reacts to events sent by the
ImageRepositoryobjects, if by chance the scanning happens in parallel for multiple repos and all of them have updates, those will be included in the same commit.Wuzyn commentedon Feb 18, 2022
I have 7
ImageRepositoryobjects defined, each of them havingintervalset to1m. My IAC have interval set to10m. So that means IAC is ignoring it'sintervalproperty?If I had
ImageRepositoryinterval set to1hwith IAC set to10mwould IAC trigger repository scanning every 10 minutes?stefanprodan commentedon Feb 18, 2022
Yes, all Flux controllers do this, the interval is there in case Kubernetes API goes down while an ImageRepository event is issued.
No it's the other way around, IAC reacts to ImageRepository pulling new tags.
Wuzyn commentedon Feb 22, 2022
@stefanprodan Is HelmRelease behaves the same way? Once it gets image update, it runs helm upgrade ignoring the interval?
stefanprodan commentedon Feb 22, 2022
Yes, any change event triggers a reconciliation outside the interval, no matter the Flux object.
lictw commentedon Feb 22, 2022
Okay, I understand how KS/HR works and what is reconcile (sync) interval. But this logic seems strange to me for IR/IP/IA..
From docs: (https://fluxcd.io/docs/components/image/imageupdateautomations/)
The ImageUpdateAutomation type defines an automation process that will update a git repository, based on image policy objects in the same namespace.
And will be nice if IA updates repository based on IP, not IP triggers IA. I don't see any advantages in the current approach, you can describe it, it's interesting, but in my situation, for big, unicorn chart, where 20+ policies relate single automation and CI performs parallel builds for many apps, i see how single update iteration stretch into multiply commits/updates and it's overlap.
I already inderstand that it's by design and you can close issue if everything works as it should. Sorry for my English, i hope my main minds are clean!
Wuzyn commentedon Feb 24, 2022
This is what I did as a workaround:
https://fluxcd.io/docs/components/helm/helmreleases/#reconciliation
lictw commentedon Mar 1, 2022
In general it very complicated in my case (builds come not from single repo), but i did not know about configMap behav., thanks for this! Okay, it will be 5 commits in 3 minutes, but it will be single reconcilation every 5 minutes for example. It's really what i want!
lictw commentedon Mar 9, 2022
Via kustomize configmap generator ofk? Image Update Automation wants YAML structure to change images.
kingdonb commentedon Mar 25, 2022
@lictw No, this is a clever workaround. Using the kustomize configmap generator strategy ensures that every change to the configmap gets applied right away, because the configmap has a name with hash suffix, and the hash changes every time the content changes (and so does the HelmRelease, because configmap generator is shown with
nameReference.fieldSpecsconfiguration in the example that you referenced.)This approach works for the intended purpose as @Wuzyn describes precisely because it does not take any hash or update right away. It must wait around for the interval, and not reconcile immediately on every change. HelmRelease does not have any subscription to the ConfigMap that it lists in
valuesFrom, it only knows to update whenever its spec changes, when it is notified by a source that has changed, or when it is reconciled after any input changed (either manually reconciled or due to the interval expiration).lictw commentedon Apr 18, 2022
@kingdonb I didn't fully understand your idea.. Cause of IUA wants to deal with yaml files, I didn't see way other than configmapGenerator, so I did it with generatorOption.disableNameSuffixHash and it's work fine.
About
every change to the configmap gets applied right away, because the configmap has a name with hash suffix:How? I can't apply this schema, my kustomize don't apply hash at configmap's name referenced in HelmRelease, I tried to achieve this in other task, what's wrong?
kingdonb commentedon Apr 25, 2022
The example linked provides this snippet:
In this case,
spec/valuesFrom/nameis the path in the HelmRelease which Kustomize searches for values of secret (or configmap) names that are matching the secret (or cm) generator, so that Kustomize can substitute the generated name with the hash suffix there. That's what it looks like you're missing, you need to add:or whatever name you prefer for this Kustomize config file, and then Kustomize will make the substitutions whenever the secret/cm has changed in the generator.
Spittal commentedon Jun 25, 2024
Hey, I understand that
ImageAutomationControllerreacting toImageRepositoryand the subsequentImagePolicyupdates is desired behaviour but I wish there was a 'window' to capture changes.For example we have 4
ImageRepositoryobjects with correspondingImagePolicyand they update ~10 seconds of each other. Sometimes we get lucky and a singleImageAutomationControllercommit will contain multiple image updates, but often we get a separate commit perImagePolicyupdate. This ends up being noise in our commit history, and is something I wish we had more control over.A solution could be that on the
ImageAutomationController.specthere could exist awindowparameter that will wait a certain amount of time after a reconciliation was triggered to 'collect' any moreImagePolicyupdates that might be coming before committing to the repo.makkes commentedon Jun 26, 2024
@Spittal One way to mitigate having multiple commits in your history is to let IAC push to a specific branch and automatically create a PR (or MR in GitLab terms) from that branch. Then you can squash the commits before merging.
kingdonb commentedon Jun 26, 2024
A challenge to implement a wait is that maybe the images usually arrive within 10s of each other, but maybe it's sometimes a bit longer. How do you decide the timeout? The longer you make it, the longer people perceive that it takes for IUA to do its job.
Pull requests that get merged at a point in time are a good solution for this. You wait until you see all the necessary changes, then merge it. With squash merges you won't necessarily even be able to tell they weren't one commit.
It could still be a nice feature but it sounds like a hack. If another image comes in, do you reset the timeout or keep counting? If people set the timeout too long and have too many imageupdateautomations, it will hang the controller. They will have to increase the concurrency and things will generally take longer.
What you're looking for is probably better served by a tool like Kargo (Christian Hernandez presented this at Bug Scrub last week and the week before!)
It can work with Flux!
Spittal commentedon Jun 26, 2024
Yeah, it certainly has that feeling. We spoke internally at length about this because the only "downside" we identified with the current Flux behavior is that it's creating multiple commits, which feels unintuitive. However, when our images inevitably diverge in the speed of building, then an IAC
windowfeature becomes a moving target like you described above.Furthermore, another way to look at this is that Flux is attempting to update as fast as possible, and that's something we actually want in our deployments.
I think something that would've been really helpful for us to come to that conclusion earlier would be a mention in all
intervaldocs that describes this.If that's something that you'd be interested in I can take a swing at a PR for this doc change BTW.
Thanks for the quick replies!
P.S. Thanks for the Kargo recommendation. We have seen this floating around but haven't dug into it. Looking forward to taking a look!
fhoekstra commentedon Sep 4, 2026
We have the same situation and desire as Spittal describes above: we reconcile new images in staging via ImageUpdateAutomation, and many images are built/pushed within seconds of each other, cluttering up our git log with image update commits.
We don't mind waiting a few minutes when a new image is pushed, to have a cleaner commit log.
For us, it's a trade-off in commit log spam in our monorepo vs speed. That's why batching should be opt-in.
I envision adding a
spec.batchingfield withspec.batching.enabled,spec.batching.windowand any future additions (batching strategy?) could go underspec.batchingtoo if desired? Alternatively, just aspec.batchingWindowthat isnullby default.Thanks for raising this! I see 3 possible ways to do batching:
statusfield?) to keep track of when the window started. Introduces significant complexitythe third way seems sensible, if this is going to be implemented at all, as this is clearly not a very hot topic (it's been quiet on this issue for 2 years), and that way introduces the least complexity and maintenance burden to the project.
Would you be open to further discussion or a PR for this?
matheuscscp commentedon Sep 4, 2026
There's no way for a Reconcile() to know what triggered it: an ImagePolicy watch event or the interval.
If you need time-based image automation I recommend using Flux Operator's ResourceSet:
https://fluxoperator.dev/docs/resourcesets/time-based-delivery/
fhoekstra commentedon Sep 9, 2026
Thanks for your pointer @matheuscscp : ResourceSets are not just useful for time-based automation, but also simply keeping things in sync with an OCI registry without requiring commits to the GitOps repo.
We have set up something like the following, where we:
images:block from a generic ResourceSet (essentially a template)This ensures each app is continuously updated with a new digest as new images get pushed to that tag, without anything getting automatically committed to Git by Flux.
Of course, we could also add a
cronto the ResourceSet to limit when or how often it updates, but we find we just wanted to reduce the number of automated commits in our Git log, not actually slow down the sync.It looks something like this: