1.8 KiB
Automatic Image Updates
If you want flux to automatically update container images, this is how. Based on this documentation.
Make the deployment
Start by making a normal deployment how you would normally. Just note not to use latest
as your tag.
(You shouldn't be anyways).
Add an image scanner
Create an image scanner to go pull new image versions.
flux create image repository MYNAME \
--image=git.clortox.com/infrastructure/my-cool-image \
--internal=5m \
--export > MYNAME-registry.yaml
Next make the ImagePolicy
to choose what semver to filter for.
flux create image policy MYNAME \
--image-ref=MYNAME \
--select-semver=0.0.x \
--export > MYNAME-policy.yaml
Configure Image Updates
At this point flux can scan peridoically and see that new images are released. Now lets automatically pull them down, and update the git repo.
First, we have to tell flux where it should apply updates in our manifests. To do that, add the following comment to the end of the line in your deployment
image: git.clortox.com/infrastructure/gluttony-cluster/documentation:0.0.1 # {"$imagepolicy": "flux-system:MYNAME"}
The syntax here is NAMESPACE:IMAGE_POLICY_NAME
.
After this, lets make the updater for the entire system.
flux create image update flux-system \
--interval=15m \
--git-repo-ref=flux-system \
--git-repo-path="./cluster" \
--checkout-branch=main \
--push-branch=main \
--author-name=fluxcdbot \
--author-email=fluxcdbot@users.noreply.github.com \
--commit-template="{{range .Changed.Changes}}{{print .OldValue}} -> {{println .NewValue}}{{end}}" \
--export > ./flux-system-automation.yaml
Note
flux-system
is the default source name. Check it withflux get source git