Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL an application with the same name and a different base already exists, consider choosing a different name #470

Open
hookenful opened this issue May 20, 2023 · 4 comments

Comments

@hookenful
Copy link

Hi there!

I am trying to create the same app for different projects (environments)

argocd-autopilot application create frontend --app http://192.168.0.78:8080/root/machairodus-new/web/kustomize/envs/dev?ref=1.5 --project dev--dest-namespace dev

argocd-autopilot application create frontend --app http://192.168.0.78:8080/root/machairodus-new/web/kustomize/envs/test?ref=1.5 --project test --dest-namespace test

In result I have an error:

FATAL an application with the same name and a different base already exists, consider choosing a different name

How should I specify different kustomize manifests for different envs? Is there any working example to achieve that with argocd-autopilot

@neeraj-ec
Copy link

I think this happens when you have kustomization files in the same git repo which is used by argocd-autopilot. For example you created your app yaml files in $GIT_REPO/apps/sample-app/overlayes/dev. Here $GIT_REPO is same git repo you used for export GIT_REPO=https://....

I'm also struggling with the same issue. The documentation about this project poor and skips a lot of details and too hard to follow for new gitops user who does not have much knowledge about argocd.

@noam-codefresh Is it mandatory to keep your application yaml files somewhere else other than $GIT_REPO/apps/app1/overlays/project1. If yes I don't understand how it achieve gitops then? If I'm putting my yaml files in some other dir or git repo then how argocd will reconcile? Because it is watching $GIT_REPO/apps/app1/overlays/project1 directory for changes and any new deployment will make changes in yaml files which are at some other place.


My file structure is

.
├── apps/
│   └── app1/
│       ├── base/
│       │   ├── dep.yaml
│       │   ├── configs.yaml
│       │   ├── service.yaml
│       │   ├── ingress.yaml
│       │   └── kustomization.yaml
│       └── overlayes/
│           ├── dev/
│           │   └── kustomization.yaml
│           ├── prod/
│           │   └── kustomization.yaml
│           └── stage/
│               └── kustomization.yaml
├── bootstrap
└── projects

I create apps/app1 directory manually, commit to $GIT_REPO and then run the command
argocd-autopilot app create app1 --app $GIT_REPO/apps/app1/overlays/dev/ --project dev --type kustomize --wait-timeout 2m

And I get the error.

FATAL an application with the same name and a different base already exists, consider choosing a different name

@noam-codefresh @danielm-codefresh Can somebody please help me understand whats I'm doing wrong?

@neeraj-ec
Copy link

Found a solution. if you create a file apps/app1/overlays/dev/config.json with content like

{
    "appName": "app1",
    "userGivenName": "app1",
    "destNamespace": "test",
    "destServer": "https://kubernetes.default.svc",
    "srcPath": "apps/app1/overlays/dev",
    "srcRepoURL": "https://github.com/example/example.git",
    "srcTargetRevision": "",
    "labels": null,
    "annotations": null
  }

it will automatically create the app. You don't even need to run argocd-autopilot app create ... command. srcRepoURL is the url of your $GIT_REPO.

Basically this is dictated by the ApplicationSet created when you create a project. You can look at projects/project1.yaml file which determines which path it monitor to look for config.json and config_dir.json. These are part of Git Generators

I understood the usage of config.json. But still does not know how config_dir.json is used and when should I create config_dir.json over config.json + what benefits it provides + what should be the content in config_dir.json.
If someone from codefresh team can shed a some light on it.

@hookenful
Copy link
Author

hookenful commented Jun 2, 2023

@neeraj-ec I think u just need to keep your base app manifests outside gitops repository (e.g in app repository), but after u argocd-autopilot app create ..., you can manually add overlay where u specify params, especially image and etc.. So after that, u can modify that image section in gitops repository and argocd will reconcile.

@noam-codefresh am I right with that?

@neeraj-ec
Copy link

@neeraj-ec I think u just need to keep your base app manifests outside gitops repository (e.g in app repository), but after u argocd-autopilot app create ..., you can manually add overlay where u specify params, especially image and etc.. So after that, u can modify that image section in gitops repository and argocd will reconcile.

@noam-codefresh am I right with that?

That is one way of doing it. But I want to keep all my manifests files in a single infra repository. Managing whole k8s cluster from single repo. In that case, #470 (comment) works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants