|
| 1 | +# Argo CD single-apply example (CloudNativePG + coder-k8s) |
| 2 | + |
| 3 | +This example bootstraps the full stack from one `ApplicationSet`. |
| 4 | + |
| 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`) |
| 9 | +3. CloudNativePG PostgreSQL `Cluster` |
| 10 | +4. `CoderControlPlane` |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- A Kubernetes cluster |
| 15 | +- `kubectl` configured for that cluster |
| 16 | +- Argo CD installed (including the ApplicationSet controller) |
| 17 | +- Argo CD v2.6+ (required for `spec.sources` in the generated Application) |
| 18 | + |
| 19 | +## Apply one manifest |
| 20 | + |
| 21 | +```bash |
| 22 | +kubectl apply -f examples/argocd/applicationset.yaml |
| 23 | +``` |
| 24 | + |
| 25 | +That creates: |
| 26 | + |
| 27 | +- `ApplicationSet` `coder-k8s-stack` |
| 28 | +- generated `Application` `coder-k8s-stack` |
| 29 | + |
| 30 | +## Ordering behavior |
| 31 | + |
| 32 | +This setup avoids app-of-apps ordering ambiguity by using a single generated `Application` with multiple sources. |
| 33 | + |
| 34 | +Resource-level sync waves provide dependency ordering for workload resources: |
| 35 | + |
| 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` |
| 40 | + |
| 41 | +## Watch rollout |
| 42 | + |
| 43 | +```bash |
| 44 | +kubectl -n argocd get applications |
| 45 | +kubectl -n coder wait --for=condition=Ready cluster/coder-db --timeout=10m |
| 46 | +kubectl -n coder rollout status deployment/coder --timeout=10m |
| 47 | +``` |
| 48 | + |
| 49 | +## Access Coder |
| 50 | + |
| 51 | +```bash |
| 52 | +kubectl -n coder port-forward svc/coder 3000:80 |
| 53 | +``` |
| 54 | + |
| 55 | +Open <http://localhost:3000/setup> and complete the setup flow. |
| 56 | + |
| 57 | +## Customization |
| 58 | + |
| 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. |
| 63 | + |
| 64 | +## Cleanup |
| 65 | + |
| 66 | +```bash |
| 67 | +kubectl -n argocd delete applicationset coder-k8s-stack |
| 68 | +``` |
| 69 | + |
| 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. |
0 commit comments