# Flux image automation: watches the Forgejo registry for new hello-app # tags, and rewrites deployment.yaml's image tag + commits back to this repo # when one shows up. Requires clusters/homelab/flux-system to have write # access to the Forgejo repo (flux bootstrap sets this up). # # ImageUpdateAutomation must live in the SAME namespace as the ImagePolicy # it targets - the controller only ever lists ImagePolicy objects from its # own namespace (internal/controller/imageupdateautomation_controller.go's # getPolicies() scopes the List() call to obj.Namespace), so a # cross-namespace $imagepolicy marker silently matches nothing and every # reconcile reports "repository up-to-date" with no commit, regardless of # how correct the marker/RBAC/policy resolution otherwise are. GitRepository # itself can still be referenced cross-namespace via sourceRef.namespace. apiVersion: image.toolkit.fluxcd.io/v1 kind: ImageRepository metadata: name: hello-app namespace: hello-app spec: image: git.boglabob.com/codegit/hello-app interval: 1m # Uncomment + create the secret if the package is private. # secretRef: # name: forgejo-registry --- apiVersion: image.toolkit.fluxcd.io/v1 kind: ImagePolicy metadata: name: hello-app namespace: hello-app spec: imageRepositoryRef: name: hello-app policy: numerical: order: asc filterTags: pattern: '^main-[a-f0-9]+-(?P\d+)$' extract: '$ts' --- apiVersion: image.toolkit.fluxcd.io/v1 kind: ImageUpdateAutomation metadata: name: hello-app namespace: hello-app spec: interval: 1m sourceRef: kind: GitRepository name: flux-system namespace: flux-system git: checkout: ref: branch: main commit: author: email: flux@boglabob.com name: fluxcdbot messageTemplate: | chore(hello-app): auto-update image {{ range $resource, $changes := .Changed.Objects -}} {{ range $_, $change := $changes -}} {{ $change.NewValue }} {{ end -}} {{ end -}} push: branch: main update: path: ./apps/hello-app strategy: Setters