Use Case: Updating an Nginx Deployment
Imagine you maintain a Git repo containing Kubernetes manifests for an Nginx application. The Deployment initially pins the image tag to1.0.0:
1.2.0), Flux’s Image Automation can detect that change and automatically update your manifest in Git.
These examples use Flux CLI v0.34+. Adjust flags if you’re on an earlier release.
Flux Image Automation Components
The automation workflow involves two controllers working together:| Component | Resource Kinds | Purpose |
|---|---|---|
| Image Reflector Controller | ImageRepository, ImagePolicy | Scans container registries and resolves tags |
| Image Automation Controller | ImageUpdateAutomation | Clones Git repo, updates manifests, pushes commits |
1. Image Reflector Controller
This controller watches your container registry and picks the latest tags based on a policy.-
Create an ImageRepository
Configure Flux to scan your registry every minute: -
Define an ImagePolicy
Filter tags via Semantic Versioning. For example, to allow any minor or patch bump within1.x.0: -
Verify Scans and Policy Resolution
Example output:
Ensure your registry credentials are correctly configured so Flux can access private repositories.
2. Image Automation Controller
This controller takes the resolved image tag and injects it into your Git repository.-
Create an ImageUpdateAutomation
Point Flux at your Git repo path and specify commit details: -
Annotate Your Deployment
Mark the image field with the policy reference so Flux knows which tags to update: -
Observe the Automation
After Flux commits the update, you’ll see:
Workflow Summary
- Registry Scan: Image Reflector fetches new tags.
- Policy Resolve: ImagePolicy picks the latest eligible tag.
- Git Update: Image Automation clones your repo and updates the annotated fields.
- Commit & Push: Changes are pushed back to Git and then applied to the cluster via Flux.