Skip to main content
In this lesson you’ll use Flux’s ImageUpdateAutomation to automatically update manifests in a Git repository with the latest image tag and have Flux apply the change to your Kubernetes cluster. High-level flow:
  • An ImageRepository scans a container registry for tags.
  • An ImagePolicy resolves the desired tag (for example, latest patch).
  • ImageUpdateAutomation checks out the Git repo, updates the marked image string in the manifests, commits the change, and pushes it back to the repository.
  • Flux (GitRepository + Kustomize/Helm/manifest controllers) picks up the update and rolls out the new image in-cluster.
Benefits:
  • Automated image promotions from registry to manifests to cluster.
  • Auditable Git commits for image updates.
  • Fine-grained control via ImagePolicy and inline markers in manifests.

1) View the CLI help for ImageUpdateAutomation

Use the flux CLI to inspect usage, flags, and examples:
Tip: The CLI examples show the commit template and branch options you can use to control commit messages and the branch that receives automated updates.

2) ImageUpdateAutomation resource

Create an ImageUpdateAutomation resource that points at a Flux GitRepository (Source) and the path inside that repository where manifests should be updated. Example YAML:
Explanation of important fields Apply this YAML (for example kubectl apply -f image-update.yaml) or use flux create image update to generate and install the resource.

3) GitRepository (Flux Source) that holds manifests

The ImageUpdateAutomation points to a Flux GitRepository source that references the repo and branch being updated. Example GitRepository YAML:
ImageUpdateAutomation will check out the branch 8-demo and update files under ./manifests in that repository.

4) Mark the exact image line in your manifest

ImageUpdateAutomation needs an inline marker to identify which image string to replace. Add a JSON-style comment on the same line as the image: field to reference an ImagePolicy. Example Deployment manifest (marker on the image line):
Key points:
  • The marker must be on the same line as the image string.
  • The marker format is a JSON comment such as # {"$imagepolicy": "namespace:policy-name"}. Use inline code formatting when documenting this pattern: # {"$imagepolicy": "namespace:policy-name"}.
  • The referenced ImagePolicy will control how tags are selected (for example, latest minor/patch).
Keep the JSON marker and the image string on the same line. The marker tells ImageUpdateAutomation which ImagePolicy to consult when resolving the new tag.

5) Check current image scanning and update status

Use flux get images all to inspect image repository scans, policy resolutions, and ImageUpdateAutomation status:
Possible reasons ImageUpdateAutomation reports “no updates made”:
  • The manifest already matches the resolved tag (no change required).
  • The controller could not locate the marker in the file.
  • An update was required but the controller could not commit/push due to missing authentication.

6) Authentication required: deploy key (SSH) for repository push

If ImageUpdateAutomation finds an update but shows authentication errors, Flux does not have push permissions. Provide Flux a Git deploy key and store the private key in a Kubernetes secret. Example: generate a deploy key secret with the flux CLI (sample uses ECDSA P-521):
  • The command prints a public deploy key (the long string starting with ecdsa-sha2-nistp521 ...). Add this public key to the repository’s Deploy Keys in GitHub and grant write access so Flux can push commits.
  • The private key is stored in the Kubernetes secret 8-demo-git-bb-app-auth in the flux-system namespace.
When registering the deploy key in GitHub, grant write access (allowing pushes) if you want ImageUpdateAutomation to push commits. Otherwise Flux will be able to read but not write.
When using a deploy key for push access you must use the SSH URL for the repository (ssh://git@github.com/...) and configure the GitRepository to reference the secret that stores the private key.

7) Update the GitRepository resource to use the SSH URL and secretRef

Update (or recreate/export) the GitRepository so Flux clones using SSH and the secret you created: Example command that exports the updated resource:
Resulting YAML will include secretRef and the SSH URL:
Apply this updated GitRepository so Flux uses the SSH key for authenticated operations.

8) Reconcile and confirm updates

After you:
  • Add the image marker to the Deployment manifest,
  • Create the deploy key secret and add the public key to GitHub with write access, and
  • Update the GitRepository to reference the SSH URL and secret,
ImageUpdateAutomation should:
  1. Resolve the latest tag via the ImagePolicy,
  2. Update the marked image line in the manifest,
  3. Commit the change using the configured author identity,
  4. Push the commit to the specified branch.
Commands to confirm status and rollout:
If everything is configured correctly, the Deployment will reflect the new image tag that ImagePolicy resolved and ImageUpdateAutomation committed.
A browser window showing an arcade-style "BLOCK BUSTER" game screen with a metadata panel at the top listing pod details (Pod Name, Pod IP, Namespace, K8S Node, App Version). The main play area displays "PRESS START" with level/score indicators across the top and a green "START GAME" button at the bottom.

Summary

  • Use ImageRepository to scan registry tags and ImagePolicy to resolve which tag to use.
  • Create an ImageUpdateAutomation that references your GitRepository source and the path to the manifests.
  • Mark the manifest image line with an inline JSON comment that references the ImagePolicy: # {"$imagepolicy": "namespace:policy-name"}.
  • If ImageUpdateAutomation must push commits, provide Flux push credentials (deploy key) and configure the GitRepository to use the SSH URL and secretRef.
  • Monitor with flux get images all and flux get images update, and verify the Deployment image with kubectl.
Links and references

Watch Video

Practice Lab