Skip to content

Commit f1081fc

Browse files
committed
πŸ€– fix: remove app-of-apps ordering ambiguity in Argo example
Refactor the Argo CD example so the ApplicationSet generates one multi-source Application instead of a parent app that applies child Application resources. This avoids cross-Application wave ordering ambiguity, adds a cascading resources finalizer for cleanup, and keeps dependency ordering at the resource level via sync waves. --- _Generated with [`mux`](https://github.com/coder/mux) β€’ Model: `openai:gpt-5.3-codex` β€’ Thinking: `xhigh` β€’ Cost: `$0.56`_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.56 -->
1 parent f35546f commit f1081fc

6 files changed

Lines changed: 54 additions & 100 deletions

File tree

β€Žexamples/argocd/README.mdβ€Ž

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Argo CD single-apply example (CloudNativePG + coder-k8s)
22

3-
This example bootstraps the full stack from one `ApplicationSet`:
3+
This example bootstraps the full stack from one `ApplicationSet`.
44

5-
1. CloudNativePG operator
6-
2. `coder-k8s` operator stack (CRDs + RBAC + deployment)
5+
The generated Argo CD `Application` uses multiple sources to deploy:
6+
7+
1. CloudNativePG operator (Helm chart)
8+
2. `coder-k8s` operator stack (`config/crd/bases`, `config/rbac`, `deploy`)
79
3. CloudNativePG PostgreSQL `Cluster`
810
4. `CoderControlPlane`
911

@@ -12,7 +14,7 @@ This example bootstraps the full stack from one `ApplicationSet`:
1214
- A Kubernetes cluster
1315
- `kubectl` configured for that cluster
1416
- Argo CD installed (including the ApplicationSet controller)
15-
- Argo CD v2.6+ (required for Application `sources` in `apps/01-coder-k8s-operator.yaml`)
17+
- Argo CD v2.6+ (required for `spec.sources` in the generated Application)
1618

1719
## Apply one manifest
1820

@@ -23,14 +25,18 @@ kubectl apply -f examples/argocd/applicationset.yaml
2325
That creates:
2426

2527
- `ApplicationSet` `coder-k8s-stack`
26-
- parent `Application` `coder-k8s-stack`
27-
- child Applications in `examples/argocd/apps/`
28+
- generated `Application` `coder-k8s-stack`
29+
30+
## Ordering behavior
2831

29-
### Ordering behavior
32+
This setup avoids app-of-apps ordering ambiguity by using a single generated `Application` with multiple sources.
3033

31-
`apps/00-cnpg-operator.yaml` and `apps/01-coder-k8s-operator.yaml` are synced in wave `0`, and `apps/02-coder-cloudnativepg.yaml` in wave `1`.
34+
Resource-level sync waves provide dependency ordering for workload resources:
3235

33-
The CloudNativePG example manifests (`examples/cloudnativepg/`) also include resource-level sync waves so PostgreSQL is applied before `CoderControlPlane`.
36+
- `examples/argocd/resources/00-coder-system-namespace.yaml` uses `wave -1`
37+
- `examples/cloudnativepg/00-namespace.yaml` uses `wave 0`
38+
- `examples/cloudnativepg/cnpg-cluster.yaml` uses `wave 1`
39+
- `examples/cloudnativepg/codercontrolplane.yaml` uses `wave 2`
3440

3541
## Watch rollout
3642

@@ -50,15 +56,15 @@ Open <http://localhost:3000/setup> and complete the setup flow.
5056

5157
## Customization
5258

53-
- This example tracks `https://github.com/coder/coder-k8s.git` at `main` for child apps.
54-
Update `repoURL` and `targetRevision` in `examples/argocd/apps/*.yaml` if you want to pin to a tag or use a fork.
55-
- `apps/00-cnpg-operator.yaml` uses `targetRevision: "*"` for the CloudNativePG chart.
56-
Pin this to a specific chart version for reproducibility.
59+
- This example tracks `https://github.com/coder/coder-k8s.git` at `main`.
60+
Update `repoURL` and `targetRevision` in `examples/argocd/applicationset.yaml` if you want to pin to a tag or use a fork.
61+
- The CloudNativePG chart version is configurable with `cloudnativepgChartVersion`.
62+
Pin it to an explicit chart version for reproducible environments.
5763

5864
## Cleanup
5965

6066
```bash
6167
kubectl -n argocd delete applicationset coder-k8s-stack
6268
```
6369

64-
Depending on your storage class reclaim policy, PVCs from PostgreSQL may remain after cleanup.
70+
The generated `Application` includes `resources-finalizer.argocd.argoproj.io` so deleting the `ApplicationSet` cascades cleanup of managed resources. Depending on your storage class reclaim policy, PVCs from PostgreSQL may remain after cleanup.

β€Žexamples/argocd/applicationset.yamlβ€Ž

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,44 @@ spec:
1414
elements:
1515
- name: coder-k8s-stack
1616
destinationServer: https://kubernetes.default.svc
17+
destinationNamespace: cnpg-system
1718
repoURL: https://github.com/coder/coder-k8s.git
1819
targetRevision: main
19-
path: examples/argocd/apps
20+
cloudnativepgChartVersion: "*"
2021
template:
2122
metadata:
2223
name: "{{ .name }}"
2324
namespace: argocd
25+
finalizers:
26+
- resources-finalizer.argocd.argoproj.io
2427
labels:
2528
app.kubernetes.io/part-of: coder-k8s-example
2629
spec:
2730
project: default
28-
source:
29-
repoURL: "{{ .repoURL }}"
30-
targetRevision: "{{ .targetRevision }}"
31-
path: "{{ .path }}"
31+
sources:
32+
- repoURL: https://cloudnative-pg.github.io/charts
33+
chart: cloudnative-pg
34+
targetRevision: "{{ .cloudnativepgChartVersion }}"
35+
helm:
36+
releaseName: cnpg
37+
- repoURL: "{{ .repoURL }}"
38+
targetRevision: "{{ .targetRevision }}"
39+
path: examples/argocd/resources
40+
- repoURL: "{{ .repoURL }}"
41+
targetRevision: "{{ .targetRevision }}"
42+
path: config/crd/bases
43+
- repoURL: "{{ .repoURL }}"
44+
targetRevision: "{{ .targetRevision }}"
45+
path: config/rbac
46+
- repoURL: "{{ .repoURL }}"
47+
targetRevision: "{{ .targetRevision }}"
48+
path: deploy
49+
- repoURL: "{{ .repoURL }}"
50+
targetRevision: "{{ .targetRevision }}"
51+
path: examples/cloudnativepg
3252
destination:
3353
server: "{{ .destinationServer }}"
34-
namespace: argocd
54+
namespace: "{{ .destinationNamespace }}"
3555
syncPolicy:
3656
automated:
3757
prune: true

β€Žexamples/argocd/apps/00-cnpg-operator.yamlβ€Ž

Lines changed: 0 additions & 26 deletions
This file was deleted.

β€Žexamples/argocd/apps/01-coder-k8s-operator.yamlβ€Ž

Lines changed: 0 additions & 30 deletions
This file was deleted.

β€Žexamples/argocd/apps/02-coder-cloudnativepg.yamlβ€Ž

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: coder-system
5+
annotations:
6+
argocd.argoproj.io/sync-wave: "-1"
7+
labels:
8+
app.kubernetes.io/part-of: coder-k8s-example

0 commit comments

Comments
Β (0)