Skip to content

[Question] Multiple environments(dev, stage, ..,. prod ) example #57

Open
@emirot

Description

@emirot

Hi there,

I'm getting started with Argocd.
I was able to run great examples, but I don't understand how multiple environments (dev, stage, prod) are managed.

Do I have to create an application for each environment ?

Activity

taybur43

taybur43 commented on Oct 23, 2020

@taybur43

Please provide a doc describing details of Managing multiple env in argocd.

davenmth

davenmth commented on May 10, 2021

@davenmth

Simple question and no answer in 10 months. The app of apps pattern works in most cases pretty good. You need to create a parameterized app template and then the values files for each environment.
The biggest pain is that the names must be global galactically unique, which means you cannot deploy an app to multiple environments without modifying its name.

yangvipguang

yangvipguang commented on Jun 25, 2021

@yangvipguang

any answers?

viyorv

viyorv commented on Jun 25, 2021

@viyorv

It would be nice to get an answer from argocd

danghung-dev

danghung-dev commented on Jun 29, 2021

@danghung-dev

I also need an answer

ayushkr04

ayushkr04 commented on Aug 12, 2021

@ayushkr04

do we any updates on this one?
How to manage multiple environments with ArgoCD.

kostis-codefresh

kostis-codefresh commented on Nov 5, 2021

@kostis-codefresh
Member

Hello.

The reason that this question has been not answered, is that there is no standard answer. Most companies do something different and either have an ad-hoc solution or something with an external system or a custom thing over app-of-apps, appset, argo-autopilot etc.

As an example, I could provide you with a detailed answer of what we do to address this, until you realize that all my environments are different folders on a single monorepo and my solution depends on this choice. If you have chosen to have different branches per environment for your own case instead, then all my advice is useless to you.

And then let's say that you are lucky and I also follow the branch-per-environment practice in git. But then we find out that I am doing git-flow development while you are doing trunk-based development.

And then we have to answer this question for Helm, for kustomize, for plain manifests, for people with declarative setup, for people with application sets etc. The possible scenarios get quickly out of hand.

By the way this is not a problem specific to Argo CD. It is a problem with GitOps in general.
See points 3 and 4 here https://codefresh.io/about-gitops/pains-gitops-1-0/

The GitOps working group is now formed (check https://opengitops.dev/) and will soon address all these questions (and more) and establish best practices and standards.

qxmips

qxmips commented on Nov 30, 2021

@qxmips

anyway would be helpful to have an examples directory with various senarious

kostis-codefresh

kostis-codefresh commented on Nov 30, 2021

@kostis-codefresh
Member

@qxmips It is already on my TODO list. Stay tuned :-)

kostis-codefresh

kostis-codefresh commented on Mar 23, 2022

@kostis-codefresh
Member
taybur43

taybur43 commented on Mar 26, 2022

@taybur43
ReubenTheDS

ReubenTheDS commented on Apr 7, 2022

@ReubenTheDS

@kostis-codefresh , very informative articles and repo, thank you. I'm in the process of implementing what you've suggested, in my employers' projects. I'd like some clarifications on the following points:

  • If I understood the code & articles correctly, it seems like you suggest using 1 docker image for all environments. For example "simple-env-app" will be used across staging, qa & prod envs. Is this correct?
  • is the above point in line with the concept of artifact promotion? If not, please elaborate or link an article.
  • If I'm using Jenkins for CI, are the following steps for release mgmt correct?
    • testing in QA: CI tool (like GitHub Actions, GitLab runner or Jenkins) runs the command "kustomize edit set image ..." on "env/qa/version.yaml" ... testing in QA commences ...
    • for promotion to staging: the CI tool copies "env/qa/version.yaml" to "env/staging/version.yaml" - the only confusion here is do I have multiple Jenkinsfiles for each env? If I want to use just one Jenkinsfile for both the above envs & tasks, how would I go about doing that? Or have I completely misunderstood all of this (do you have an example repo)?
  • Separately, let's say that the application in different regions use different CA certificates. How do you suggest this is handled? Does the Dockerfile (& therefore the image) load all the certificates & then use ENV variables? ( CA cert might be one region-specific example, there might be other settings. Does the image load all the settings & use just ENV variables for distinguishing? )
kostis-codefresh

kostis-codefresh commented on Apr 8, 2022

@kostis-codefresh
Member

Hey @ReubenTheDS

Thank you for the feedack.

  1. Yes the same docker image should be promoted to all environments (but with different configuration). Actually this was a good practice already before Kubernetes/Gitops and goes all the way back to the Heroku guidelines

  2. Yes it is. I didn't cover this on the blog post because I have already written about it elsewhere. Check points 5 and 8 on the Docker anti-patterns article, point 2 in the Kubernetes anti-patterns article and point 2 in the CI/CD best practices article

  3. Yes these are correct. I don't use Jenkins for some time now, but if I remember correctly you can have a Jenkinsfile with parameters. So you should create a single Jenkinsfile with parameters for source and target environment. If you have a small number of environments then I guess you could also use multiple Jenkinsfiles and it should work just fine. You need to check the Jenkins 2.x documentation. I don't think this question is related to GitOps/ArgoCD

  4. Very good question. I have seen both practices in the field. I personally suggest the container does NOT include the CA certificates for all possible configurations. You can fetch them during deployment. There are many ways to do this in Kubernetes such as using mounted volumes/init containers. Again this question is not related to ArgoCD.

Jaykob

Jaykob commented on Oct 10, 2023

@Jaykob

@kostis-codefresh Thanks for these really helpful recommendations and your guide!

Can you please elaborate a bit on how the single-docker-image approach mentioned above in answer 1. is supposed to work during active development of a product?
I mean we usually add features and they'll end up in a staging environment at some point while production is still running a stable version of that docker image.
How are we supposed to use the same image for staging and production in my example?

kostis-codefresh

kostis-codefresh commented on Oct 10, 2023

@kostis-codefresh
Member

@Jaykob Not sure I understand what you are asking. The "staging" image should be promoted to production at some point. And then both envs are the same.

Or are you saying that you have some features that go to staging and stay there? And they never go to production?

The original best practice doesn't say that you should be running the same image at all env AT ALL TIMES. It simply says that you should create an image once and then promote it to all environments gradually (instead of building a new image for QA, a new image for staging, a new image for production and so on)

Jaykob

Jaykob commented on Oct 10, 2023

@Jaykob

Ah ok sorry, I misunderstood you on that point.
I thought you were telling us to always use the same image (version) across all environments and was seriously asking myself how that's supposed to work.
I was over reading the very important word "promote" here. Again, sorry.

BTW: Do you have good reading recommendations about doing all that with ApplicationSet?

kostis-codefresh

kostis-codefresh commented on Oct 10, 2023

@kostis-codefresh
Member

There isn't a guide similar to mine yet for applicationsets (to the best of my knowledge)

But Argo CD itself is adding features to help there. See initial support here https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Progressive-Syncs/

kostis-codefresh

kostis-codefresh commented on May 17, 2024

@kostis-codefresh
Member

@Jaykob Since several people asked me the same thing I also wrote a guide on how to use Application Sets. You can find it here https://codefresh.io/blog/how-to-structure-your-argo-cd-repositories-using-application-sets/

Jaykob

Jaykob commented on May 18, 2024

@Jaykob

@kostis-codefresh Your guide is awesome and answers so many important questions.
Thank you! 🙏

aimuz

aimuz commented on Jul 26, 2024

@aimuz

When I add a new deployment should I add it inside the base or should I add it somewhere.

For example, I have a microservices application with three services currently running in the production environment. At this point in time, due to business development, a new service is added.

If I add it to the base it will be deployed in all environments. However, I just want to deploy it in the test environment. I will only move to the next stage when I have completed the deployment in the test environment.


Single branching is great, but what should I do if I run into a situation where I need to roll back a production branch deployment? Should we care about git logging.

This is because all the changes are in a single branch, whether they are for the test environment or the qa environment. At this point, the git log should be so large that I can't tell which changes are in production!

Please feel free to correct me. Thank you.

kostis-codefresh

kostis-codefresh commented on Jul 26, 2024

@kostis-codefresh
Member

If I add it to the base it will be deployed in all environments

That doesn't happen with the setup I propose in the article. The base folder is not deployed anywhere on its own. Only overlays are in the respective environments.

Single branching is great, but what should I do if I run into a situation where I need to roll back a production branch deployment?

You run "git revert". Or even better use Argo Rollouts.

This is because all the changes are in a single branch, whether they are for the test environment or the qa environment. At this point, the git log should be so large that I can't tell which changes are in production!

Not sure what you mean by "changes". The GitHub repo has only Kubernetes manifests. So commits doesn't say anything about source code changes. Do you mean something else?

Feel free to join the argo-cd channel in the CNCF slack instance for even faster communication.

aimuz

aimuz commented on Aug 1, 2024

@aimuz

@kostis-codefresh Thank you so much, I re-read your history article and it solved my problem.

When I apply to my production I have a new problem.

For example, how should I handle things like database passwords? Is it not a best practice to store it directly in the git repository?

I would like to know how you deal with this kind of problem? How do I securely use database passwords?

kostis-codefresh

kostis-codefresh commented on Aug 1, 2024

@kostis-codefresh
Member

The topic of secrets is very popular and there are already several great sources about it.

You can store the secrets in Git but in encrypted form using Sealed Secrets. Guide here https://codefresh.io/blog/handle-secrets-like-pro-using-gitops/

Or you can store them outside of Git and fetch them from there. Guide here https://codefresh.io/blog/gitops-secrets-with-argo-cd-hashicorp-vault-and-the-external-secret-operator/

There are many more options for secrets of course. https://argo-cd.readthedocs.io/en/stable/operator-manual/secret-management/

aimuz

aimuz commented on Aug 8, 2024

@aimuz

Thank you very much @kostis-codefresh

You've helped me out a lot.

bbigras

bbigras commented on Nov 25, 2024

@bbigras

The GitOps working group is now formed (check https://opengitops.dev/) and will soon address all these questions (and more) and establish best practices and standards.

Did anything happen with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bbigras@emirot@Jaykob@danghung-dev@davenmth

        Issue actions

          [Question] Multiple environments(dev, stage, ..,. prod ) example · Issue #57 · argoproj/argocd-example-apps