GitOps with FluxCD

Hello!

I hope you are all doing well.

I’ve been working on Week 2 of the GROW project. For this, I created a new repository.

What’s happening here is that I have a FastAPI application with two different versions, to represnet different environments. A GitHub Actions workflow builds the image and stores in my GHCR. FluxCD does its magic to keep my repo and cluster up to date with the latest image tag.

Here, I encountered an issue with the ImagePolicy, and it took me a while to solve it. First, I had the Policy defined as alphabetical. It was supposed to use the commit SHA tag to create the image tag. It was working until a certain moment that it stopped working. To be honest, I couldn’t completely understand why. It had something to do, I guess, with the tag generated, based on the pattern. At some point, it stop recognizing the newer tags generated as more recent than a past one. I changed the policy to numerical, and it simply generates a number, in ascending order, that’s the workflow number. No complex patterns. I understand people prefer to use semver as policy. I may try to switch to semver.

Another thing that happened was that the Flux operator was triggering the CI workflow every second or so. I didn’t want that. I just wanted it to execute when real changes took place in the repo. To fix this, I added a paths-ignore to the trigger.

Here’s the repo, with some details of what’s happening in the README file.

Please feel free to suggest changes or improvements, or otherwise to criticize the thing.

This is another exercise I found super exciting!

Thank you!

https://github.com/rmiravalles/hello-gitops