Replace
siddharth67 below with your own Docker Hub username when building and pushing images.Overview
This tutorial covers:- Creating an ImageRepository resource to point Flux at your Docker Hub repo.
- Forcing Flux to reconcile your flux-system Git source.
- Building and pushing a new image tag to Docker Hub.
- Verifying that Flux discovers the newly pushed tag.
- Next steps: ImagePolicy and ImageUpdateAutomation to automate Git updates.
1. Create an ImageRepository resource
You can create the ImageRepository resource directly with the Flux CLI or prepare a YAML manifest and commit it to the Git repository monitored byflux-system. Below is the YAML manifest (kind: ImageRepository) used in this demo:
flux-system GitRepository.
2. Force Flux to reconcile the Git source
After committing the ImageRepository YAML, trigger an immediate reconciliation so Flux fetches the latest Git revision and applies any new resources:ImageRepository only scans the registry and reports tags. It does not change your Deployment images by itself. To automate updates you must add an ImagePolicy and ImageUpdateAutomation (or manually update the Deployment image in Git).
3. Make source changes, build a new image tag, and push to Docker Hub
Update your application source (for example, bump the app version and change UI assets), then build and push a new Docker image tag. Example Dockerfile used in the project:7.8.1):
7.8.1) is visible.
4. Confirm Flux discovers the new tag
Flux’s ImageRepository controller will scan the registry on its configuredinterval and should detect the new tag. You can force a Git reconciliation again to ensure Flux’s configuration is current, then inspect the ImageRepository status to verify discovered tags.
Force reconciliation (if needed):
lastScanResult and latestTags:
5. What’s next: automate updates with ImagePolicy and ImageUpdateAutomation
To enable fully automated GitOps image updates:- Create an
ImagePolicyto select which tags are eligible (e.g., semantic versioning rules, regex). - Create an
ImageUpdateAutomationthat updates the manifests in your Git repository when a new tag matching the policy appears. - Flux will then update the Git repository and the GitRepository controller will apply the updated manifest, updating your Deployment.
Example commands (overview):
Quick reference table: useful commands
Links and references
- FluxCD Image Toolkit: https://fluxcd.io/docs/components/image/
- FluxCD Image Update Automation: https://fluxcd.io/docs/components/image/image-update/
- Kubernetes kubectl reference: https://kubernetes.io/docs/reference/kubectl/
- Docker Hub: https://hub.docker.com