Overview
- ImageRepository discovers and lists tags for an image in a registry.
- ImagePolicy consumes an ImageRepository’s tag list and resolves a single “latest” image according to a configured policy (semver, alphabetical, numeric, etc.).
Create an ImagePolicy
The following ImagePolicy references an existing ImageRepository (named8-demo-image-repo-bb-app) and selects the highest patch version within the 7.8.x series:
How the policy selects the image
- The example uses
semverwith range7.8.x. Flux will consider tags wheremajor=7andminor=8, then pick the highest patch (e.g.,7.8.1>7.8.0). - Flux supports other policy strategies:
semver— semantic version comparison with rangesalphabetical— lexicographic comparison of tagsnumeric— numeric comparison of tag values
- You can combine
filterTagsto restrict which tags are considered (for example, to select release candidates).
Apply and let Flux reconcile
Once committed to the repository Flux manages, Flux will scan the referenced ImageRepository and resolve the latest image according to your ImagePolicy. Allow some time for the reconciliation loop to run.Inspecting results with the Flux CLI
List discovered repositories and resolved policies:status section:
Important: ImagePolicy does not mutate Deployments
Creating an ImagePolicy only resolves which tag is considered “latest” under your policy. It does not update workload manifests or change images in running Deployments by itself. For example, the workload in the8-demo namespace may still be using tag 7.8.0:
ImagePolicy resolves the latest tag per your policy but does not mutate Deployments. To automatically update manifest files (and apply those changes to the cluster via GitOps), configure ImageUpdateAutomation to commit the updated image tags to your Git repository.
Links and references
- Flux Image components: https://fluxcd.io/docs/components/image/
- Flux CLI: https://fluxcd.io/docs/flux/cli/
- ImageAutomation and ImageUpdateAutomation: https://fluxcd.io/docs/guides/image-update/
- kubectl reference: https://kubernetes.io/docs/reference/kubectl/overview/