Maven / GitOps Interview Questions
How does image automation work in Flux for continuous delivery?
Flux's image automation system closes the loop between a new container image being pushed to a registry and the updated tag being committed back to the GitOps config repository — without any CI pipeline involvement. It relies on three CRs working in sequence.
- ImageRepository: Tells Flux to scan a container registry on an interval and cache the available tags for a given image name.
- ImagePolicy: Selects the "best" tag from those discovered by the ImageRepository, using a policy rule —
semverrange, alphabetical ordering, or a regex filter. - ImageUpdateAutomation: When the ImagePolicy resolves to a new tag, this CR commits the new tag value back to the GitOps Git repository. The Kustomization's image setter marker in the YAML file (a comment annotation) tells Flux exactly which field to update.
# Step 1: scan registry for available tags
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
name: my-app
namespace: flux-system
spec:
image: registry.example.com/my-app
interval: 5m
---
# Step 2: pick the latest semver tag in the 1.x range
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImagePolicy
metadata:
name: my-app
namespace: flux-system
spec:
imageRepositoryRef:
name: my-app
policy:
semver:
range: ">=1.0.0 <2.0.0"
---
# Step 3: commit the new tag back to Git
apiVersion: image.toolkit.fluxcd.io/v1beta1
kind: ImageUpdateAutomation
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 30m
sourceRef:
kind: GitRepository
name: gitops-config
git:
commit:
author:
email: fluxcdbot@example.com
name: Flux
messageTemplate: "chore: update image to {{range .Updated.Images}}{{.}}{{end}}"
push:
branch: main
update:
path: ./apps
strategy: Setters
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
