Best practices for promotion between clusters #5667
-
Hey GitOps! I am struggling to understand how promotion between environments can be configured in a more GitOps fashion. Our use case is rather simple, we have 3 clusters (dev, staging, prod). Application X is a simple helm chart which needs to be deployed in the following fashion:
Application source code and Dockerfile are in Side notes:
There are several strategies that I have thought of but I'm a little confused as to whats the best approach. Strategy 1: PostSync job does remote git commit
This looks neat but now I need to inject a post-sync remote committing job in all my application helm charts. I also need to give write access to that job and somehow manage git SSH keys in the cluster. Strategy 2: PostSync job triggers committer workflowThis is the same as above but of doing the remote commit in the post-sync job, we trigger a workflow that does it for us. So step (4) above becomes:
The workflow could be a jenkins pipeline, argocd workflow, some ad-hoc CI pipeline etc which takes parameters like:
The job will basically update
Similarly another job could perform step (7) of creating a PR. This approach is nice because I delegate the commit logic to an external engine. However now the devs need to keep an eye on it. Strategy 3: Image updater patternThis is a pattern introduced in Flux 1 (and I think its also now supported in Flux 2). In this pattern, a controller watches image updates in a container registry (e.g. ECR) for updates, and (based on some policies) updates Lets call the controller "image updater" In our case, I could think of it in this way:
In this approach, tagging images essentially means promoting them. State of thingsI definitely want to learn how the community is attacking this problem. My concerns are: If we're triggering workflows/pipelines after syncs, this means ArgoCD becomes a "step" in the CD process. Then a CD tool like Spinnaker makes more sense where argocd sync could be a "stage" during the whole deployment? How do we provide a single workflow view to the developers who want to know at what stage their application is at the moment? I have also looked at https://github.com/maruina/argocd-progressive-rollout-controller which looks promising but its not there yet. |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 75 replies
-
I am also very interested in how everyone handles this. Currently, we store the application CRs in a central git repo that ArgoCD watches. We are going to probably do the same when we move to Application Sets. Development teams control their deployment repos which contains all their Kubernetes manifests. Then developers create PRs (we have some tooling around this to make bulk updates and such easier) to the Application CR repo to point to a different git tag or commit sha of their deployment repo. The tooling will auto merge our preproduction environments and anything to production requires an approval from our CM team. |
Beta Was this translation helpful? Give feedback.
-
Hey @musabmasood, there are two projects in the Argo CD ecosystem that might be of interest to you for accomplishing this use-case:
I'm not entirely sure that it will cover all of your requirements, but it's at least an option to think about :) |
Beta Was this translation helpful? Give feedback.
-
@musabmasood There are several steps in your plan that may need rolling back and you didn't explain how that will be accomplished. Have you looked at Argo Rollouts (analog of Flux's Flagger)? Can you let Rollouts do the syncs, using the smoke tests for validation? I read that some teams will automatically create PRs to promote the new version to each subsequent stage. You could use a successful rollout to approve the subsequent PR. The production PR could require both a successful staging rollout and manual approval. GitHub PRs can now be configured to merge automatically when all checks have passed. I think Argo Notifications can report rollout status to GitHub. |
Beta Was this translation helpful? Give feedback.
-
This is an extension to the question rather than an answer. Can someone from the Argo project create a worked example of this with whatever parts of the Argo platform? Ideally also update the docs. My use case is is very similar to the original question except as there are some older apps involved a manual hold/approval is required prior to stage and prod deploys. The entire reason I started looking at Argo was because multiple youtube video's implied that people are performing the actions described in the initial question of this thread. |
Beta Was this translation helpful? Give feedback.
-
So this is our setup right now since a few of you asked about it. Our repo looks something like this:
This is how our deployments and promotions work:
Pros:
Cons:
Would love to hear your thoughts and what you are doing about promotions. |
Beta Was this translation helpful? Give feedback.
-
Not directly answering the question but related is the Argo CD Autopilot project that specifically provides patterns for promotion across environments. |
Beta Was this translation helpful? Give feedback.
-
We are using following structure (no GitOps but Infrastructure as Code). Some of our requirements (only the ones not clarified in GitOps):
Which leads to following Question:
Therefor we came to following approach:
The benefits of such a solutions are:
Downsides:
Questions;
|
Beta Was this translation helpful? Give feedback.
-
@Hollerweger the reasons against using (GitOps) branches presented in this article make sense to me https://codefresh.io/about-gitops/branches-gitops-environments/ |
Beta Was this translation helpful? Give feedback.
-
@joebowbeer Without using environment branches I see then all the issues that are presented in this blog about GitOps: https://codefresh.io/about-gitops/pains-gitops-1-0/ Especially these points:
My suggestion from above is using both environmental branches together with folders per environment. |
Beta Was this translation helpful? Give feedback.
-
@Hollerweger both blog posts are by same author. The one you cite is over a year older. Prehistoric, that is, in terms of GitOps. I tried to use branches back then too, based on some early demos, but abandoned it. I guess we're both waiting for that next blog post... Check out how ArgoCD rolls out within Intuit: https://youtu.be/ESQLqjbM8h0 |
Beta Was this translation helpful? Give feedback.
-
We decided not to go with the "branch per cluster model" and instead "values-file-per-cluster" for now (which will be replaced with ApplicationSets soon). Nothing against the branch-per-cluster strategy but:
|
Beta Was this translation helpful? Give feedback.
-
@musabmasood and @joebowbeer: I see the same drawbacks when only using branch per envionment model. In my example i combined "branch per environment" & "folder per enviroment" to solve the main issues from both models. I don't see in your reponses that you responded to this idea. Haven't heared about ApplicationSets - need to understand what it tries to solve. I tried to update the example above and explain it in more detail: #5667 (comment) |
Beta Was this translation helpful? Give feedback.
-
Hello. @joebowbeer I am the author of the 2 Codefresh articles. Thanks for mentioning them. They have opened indeed a great discussion on how to structure repos/how to promote an app. Here is another recent view on the same subject that also briefly mentions the other approaches. Hopefully you can get some ideas until I finish writing my own proposal for environment-per-folder https://en.sokube.ch/post/promoting-changes-and-releases-with-gitops |
Beta Was this translation helpful? Give feedback.
-
This kustomize guide from OpenAnalytics is worth checking out: https://www.openanalytics.eu/blog/2021/02/23/kustomize-best-practices/ It makes a case for maintaining bases in a separate repo, in larger projects, and even maintaining a separate repo per environment. Quoting from the Structuring Kustomize Repositories section:
|
Beta Was this translation helpful? Give feedback.
-
@musabmasood , @joebowbeer , @Hollerweger , @romuduck Here is my suggested structure https://github.com/kostis-codefresh/gitops-environment-promotion Associated article with more details https://codefresh.io/about-gitops/how-to-model-your-gitops-environments-and-promote-releases-between-them/ |
Beta Was this translation helpful? Give feedback.
-
We have been versioning our repo automatically once tests pass in dev, then adjusting the "targetRevision" field in the respective Application(s) in the Argo CD instance managing the next stage of the pipeline. Prod points at a "stable" tag, which always references the commit of the last revision validated in "stage". All of the git versioning and tagging machinery is done inside GitHub actions. I wrote an article with the basic principles: https://dnastacio.medium.com/gitops-repositories-the-right-way-part-1-mapping-strategies-6409dff758b5 (see section "Lesson 2: Versioning with branches and tags") |
Beta Was this translation helpful? Give feedback.
-
I would like to point out that nowdays there is https://github.com/akuity/kargo which is taking care of promotion aspect. I think it is kind of doing what all suggestions / examples here are doing:
Basically it is doing what accepted answer suggest, you just define your At the time of writing this comment they just recently released first stable 1.0.0 version so expect:
Maybe this will be helpful for someone. |
Beta Was this translation helpful? Give feedback.
@musabmasood , @joebowbeer , @Hollerweger , @romuduck
Here is my suggested structure https://github.com/kostis-codefresh/gitops-environment-promotion
Associated article with more details https://codefresh.io/about-gitops/how-to-model-your-gitops-environments-and-promote-releases-between-them/