Skip to content

Commit 103f8d4

Browse files
committed
up
1 parent 2db1cab commit 103f8d4

2 files changed

Lines changed: 21 additions & 27 deletions

File tree

docs/argocd.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ These `AppProject` resources are defined in `infrastructure/controllers/argocd/a
8282
We use **three simple ApplicationSets** that discover applications based on their directory structure. This follows a "convention over configuration" approach, eliminating the need for metadata files.
8383

8484
### 1. The "Directory as Application" Pattern
85-
Instead of relying on marker files, our `ApplicationSet`s discover applications by looking for directories that match a predefined path pattern. The application's name and target namespace are derived directly from this path.
86-
87-
For an application at `my-apps/development/nginx`, the `ApplicationSet` will automatically:
88-
- Create an ArgoCD Application named `my-apps-development-nginx`.
89-
- Deploy the application into the `nginx` namespace.
85+
Instead of relying on marker files, our `ApplicationSet`s discover applications by looking for directories that match a predefined path pattern. The application's name and target namespace are derived directly from this path. Each `ApplicationSet` is pointed to a specific path to discover its apps:
86+
- **Infrastructure:** `infrastructure/controllers/apps/*`
87+
- **Monitoring:** `monitoring/*`
88+
- **My Apps:** `my-apps/*/*`
9089

9190
### 2. ApplicationSet Configuration
9291
All `ApplicationSet`s live in `infrastructure/controllers/argocd/apps/appsets/` and follow the same pattern. Here is the `my-apps-appset.yaml` as an example:
@@ -135,39 +134,33 @@ spec:
135134
136135
## 📂 Repository Structure
137136
138-
The repository structure is designed for clarity and co-location of configuration.
137+
The repository structure is designed for clarity and to prevent recursive management loops.
139138
140139
```
141140
├── infrastructure/
142141
│ └── controllers/
143-
│ └── argocd/ # <-- Manually bootstrapped, NOT in AppSet
144-
│ ├── apps/
145-
│ │ ├── appsets/
146-
│ │ │ ├── infrastructure-appset.yaml #<-- Ignores its own parent
147-
│ │ │ ├── monitoring-appset.yaml
148-
│ │ │ └── my-apps-appset.yaml
149-
│ │ ├── projects.yaml
150-
│ │ └── kustomization.yaml
151-
│ ├── http-route.yaml
152-
│ ├── ns.yaml
153-
│ ├── root.yaml # <-- The "root" app (App of Apps)
154-
│ ├── values.yaml
155-
│ └── kustomization.yaml # <-- The BOOTSTRAP kustomization
142+
│ ├── argocd/ # <-- Manually bootstrapped, NOT in AppSet
143+
│ │ ├── apps/ # <-- ArgoCD's OWN config (Projects/AppSets)
144+
│ │ │ └── ...
145+
│ │ └── ...
146+
│ └── apps/ # <-- Scanned by infrastructure-appset
147+
│ ├── cert-manager/
148+
│ └── ...
156149
├── monitoring/
157-
│ └── prometheus-stack/ # <-- Example discovered application
150+
│ └── prometheus-stack/ # <-- Scanned by monitoring-appset
158151
│ └── ...
159152
└── my-apps/
160153
└── development/
161-
└── nginx/ # <-- Example discovered application
154+
└── nginx/ # <-- Scanned by my-apps-appset
162155
└── ...
163156
```
164157

165158
## ✅ Key Features
166159

167160
1. **Co-located & Self-Managing ArgoCD**:
168161
- ArgoCD's entire configuration lives logically within `infrastructure/controllers/argocd`.
169-
- The `root` application manages the projects and `ApplicationSet`s from the `apps/` subdirectory.
170-
- **Crucially, the `infrastructure-appset` explicitly excludes its own directory (`.../argocd`) to prevent a recursive management loop.**
162+
- The `root` application manages the projects and `ApplicationSet`s from its own `apps/` subdirectory.
163+
- **Crucially, ArgoCD's configuration is structurally isolated from other infrastructure apps, preventing recursive management loops.**
171164

172165
2. **Enterprise Pattern**:
173166
- Clear separation of concerns with three `ApplicationSet`s.
@@ -240,7 +233,7 @@ kubectl describe application my-apps-nginx-development -n argocd
240233
| Issue | Solution |
241234
|-------|----------|
242235
| **ApplicationSet not generating apps** | Verify the directory structure matches the `path` pattern in the `ApplicationSet`. Check the `ApplicationSet` controller logs in the `argocd` namespace. Also ensure you are not accidentally excluding the path you want to deploy. |
243-
| **Recursive loop or Helm error on `infra-argocd`** | This happens if the `infrastructure-appset` discovers the `infrastructure/controllers/argocd` directory. The ApplicationSet must have a generator that explicitly excludes this path to prevent ArgoCD from trying to manage itself. |
236+
| **Recursive loop or Helm error on `infra-argocd`** | This error occurs if the `infrastructure-appset` is configured to scan a path that includes the `infrastructure/controllers/argocd` directory. The solution is to isolate discoverable applications into a dedicated subdirectory (e.g., `infrastructure/controllers/apps`) and point the ApplicationSet generator to that specific path, ensuring ArgoCD's own configuration is never discovered. |
244237
| **Applications stuck in sync** | Review application logs (`argocd app logs <app-name>`) and check for sync errors in the UI. |
245238
| **ArgoCD UI not accessible** | Check the `http-route.yaml` and the status of the `istio-ingressgateway` service. |
246239

infrastructure/controllers/argocd/apps/appsets/my-apps-appset.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ spec:
1616
- path: "my-apps/*/*"
1717
template:
1818
metadata:
19-
name: 'my-apps-{{path.elements[1]}}-{{path.basename}}'
19+
# Name is derived from the path, e.g., my-apps-ai-comfyui
20+
name: 'my-apps-{{path.segments[1]}}-{{path.segments[2]}}'
2021
namespace: argocd
2122
spec:
2223
project: my-apps
@@ -28,8 +29,8 @@ spec:
2829
buildOptions: "--enable-helm"
2930
destination:
3031
server: https://kubernetes.default.svc
31-
# Namespace is the directory name, e.g., 'ollama'
32-
namespace: '{{path.basename}}'
32+
# Namespace is the last part of the path (e.g., "comfyui").
33+
namespace: '{{path.segments[2]}}'
3334
syncPolicy:
3435
automated:
3536
prune: true

0 commit comments

Comments
 (0)