Replies: 1 comment 1 reply
-
Let's reconsider what Flux and GitOps actually are: The idea is that a single commit inside a Git repository describes the desired state. It is the reconciler's job to make sure that the reality matches the desired state. It's also the reconciler's job to find out what's necessary to bring a system into that desired state. What you propose is that a series of commits, a branch, contains a series of commands that are different in each commit that need to be executed in order to bring a system into a desired state. This is not GitOps, because the desired state is not defined by a single commit. But here is the good news: For database migrations, two production-proven tools, Flyway and Liquibase exist that perfectly solve that problem. They keep a ledger of database migration steps that are part of the application. The full list of required migration steps in in every commit, so no need to "execute" commits in order. |
Beta Was this translation helpful? Give feedback.
-
Lets assume we have two clusters A and B. Both are getting configuration from a single git repository. The main GitRepository resource is configured to be a tag. Sometimes cluster B is down for a longer period of time, meanwhile the flux configuration changes multiple times. Cluster A gets all the updates one by one, while B might jump over some commits. This can be dangerous, if some of the jumped commits are migration steps, like suspend/resume resources, creating/deleting migration jobs, enable/disable pruning.
Below is an example commit timeline. In this timeline commit 2 creates a new database and starts a migration job. The old database is then deleted in commit 3. It would be fatal for a cluster to jump from commit 1 to commit 3 or beyond.
So what I am looking for is a way to define mandatory tags for a GitRepository before rolling out the next tag. When a mandatory tag is rolled out, all Kustomizations referencing the repository need to fulfill their health checks to continue to the next tag.
Currently I have no good idea on how to mark a tag as mandatory or how to tell flux that there were mandatory tags in between. Maybe the the GitRepository would need some kind of policy for mandatory tags, that tells to only do minor updates and major updates only from tags which are referenced by the policy. Which could look maybe like this:
Somehow the source-controller would need to check:
With that we could:
I have no idea whether flux is seen as a tool to rollout migration tasks over git at all. We could of course make these migrations manually but that would again require to touch the clusters with kubectl - which should not be needed when managing migrations in a GitOps way.
Beta Was this translation helpful? Give feedback.
All reactions