Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ make docs-serve
## Examples

- [`examples/cloudnativepg/`](examples/cloudnativepg/) — Deploy a `CoderControlPlane` with a CloudNativePG-managed PostgreSQL backend.
- [`examples/argocd/`](examples/argocd/) — Bootstrap CloudNativePG + `coder-k8s` + PostgreSQL + `CoderControlPlane` from one Argo CD `ApplicationSet`.

## KIND development cluster (k9s demos)

Expand Down
64 changes: 64 additions & 0 deletions examples/argocd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Argo CD single-apply example (CloudNativePG + coder-k8s)

This example bootstraps the full stack from one `ApplicationSet`:

1. CloudNativePG operator
2. `coder-k8s` operator stack (CRDs + RBAC + deployment)
3. CloudNativePG PostgreSQL `Cluster`
4. `CoderControlPlane`

## Prerequisites

- A Kubernetes cluster
- `kubectl` configured for that cluster
- Argo CD installed (including the ApplicationSet controller)
- Argo CD v2.6+ (required for Application `sources` in `apps/01-coder-k8s-operator.yaml`)

## Apply one manifest

```bash
kubectl apply -f examples/argocd/applicationset.yaml
```

That creates:

- `ApplicationSet` `coder-k8s-stack`
- parent `Application` `coder-k8s-stack`
- child Applications in `examples/argocd/apps/`

### Ordering behavior

`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`.

The CloudNativePG example manifests (`examples/cloudnativepg/`) also include resource-level sync waves so PostgreSQL is applied before `CoderControlPlane`.

## Watch rollout

```bash
kubectl -n argocd get applications
kubectl -n coder wait --for=condition=Ready cluster/coder-db --timeout=10m
kubectl -n coder rollout status deployment/coder --timeout=10m
```

## Access Coder

```bash
kubectl -n coder port-forward svc/coder 3000:80
```

Open <http://localhost:3000/setup> and complete the setup flow.

## Customization

- This example tracks `https://github.com/coder/coder-k8s.git` at `main` for child apps.
Update `repoURL` and `targetRevision` in `examples/argocd/apps/*.yaml` if you want to pin to a tag or use a fork.
- `apps/00-cnpg-operator.yaml` uses `targetRevision: "*"` for the CloudNativePG chart.
Pin this to a specific chart version for reproducibility.

## Cleanup

```bash
kubectl -n argocd delete applicationset coder-k8s-stack
```

Depending on your storage class reclaim policy, PVCs from PostgreSQL may remain after cleanup.
40 changes: 40 additions & 0 deletions examples/argocd/applicationset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: coder-k8s-stack
namespace: argocd
labels:
app.kubernetes.io/part-of: coder-k8s-example
spec:
goTemplate: true
goTemplateOptions:
- missingkey=error
generators:
- list:
elements:
- name: coder-k8s-stack
destinationServer: https://kubernetes.default.svc
repoURL: https://github.com/coder/coder-k8s.git
targetRevision: main
path: examples/argocd/apps
template:
metadata:
name: "{{ .name }}"
namespace: argocd
labels:
app.kubernetes.io/part-of: coder-k8s-example
spec:
project: default
source:
repoURL: "{{ .repoURL }}"
targetRevision: "{{ .targetRevision }}"
path: "{{ .path }}"
destination:
server: "{{ .destinationServer }}"
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
26 changes: 26 additions & 0 deletions examples/argocd/apps/00-cnpg-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: cnpg-operator
namespace: argocd
Comment thread
ThomasK33 marked this conversation as resolved.
Outdated
annotations:
argocd.argoproj.io/sync-wave: "0"
labels:
app.kubernetes.io/part-of: coder-k8s-example
spec:
project: default
source:
repoURL: https://cloudnative-pg.github.io/charts
chart: cloudnative-pg
targetRevision: "*"
helm:
releaseName: cnpg
destination:
server: https://kubernetes.default.svc
namespace: cnpg-system
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
30 changes: 30 additions & 0 deletions examples/argocd/apps/01-coder-k8s-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: coder-k8s-operator
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
labels:
app.kubernetes.io/part-of: coder-k8s-example
spec:
project: default
sources:
- repoURL: https://github.com/coder/coder-k8s.git
targetRevision: main
path: config/crd/bases
- repoURL: https://github.com/coder/coder-k8s.git
targetRevision: main
path: config/rbac
- repoURL: https://github.com/coder/coder-k8s.git
targetRevision: main
path: deploy
destination:
server: https://kubernetes.default.svc
namespace: coder-system
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
24 changes: 24 additions & 0 deletions examples/argocd/apps/02-coder-cloudnativepg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: coder-cloudnativepg
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "1"
Comment thread
ThomasK33 marked this conversation as resolved.
Outdated
labels:
app.kubernetes.io/part-of: coder-k8s-example
spec:
project: default
source:
repoURL: https://github.com/coder/coder-k8s.git
targetRevision: main
path: examples/cloudnativepg
destination:
server: https://kubernetes.default.svc
namespace: coder
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
2 changes: 2 additions & 0 deletions examples/cloudnativepg/00-namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ apiVersion: v1
kind: Namespace
metadata:
name: coder
annotations:
argocd.argoproj.io/sync-wave: "0"
labels:
app.kubernetes.io/part-of: coder-k8s-example
2 changes: 2 additions & 0 deletions examples/cloudnativepg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ kubectl apply -f examples/cloudnativepg/

The namespace manifest is prefixed (`00-namespace.yaml`) so `kubectl apply -f` creates `coder` before namespaced resources.

These manifests also include Argo CD sync-wave annotations so the same directory works with [`examples/argocd/`](../argocd/): namespace (`wave 0`) -> CloudNativePG `Cluster` (`wave 1`) -> `CoderControlPlane` (`wave 2`).

Wait for PostgreSQL and verify the generated Secret:

```bash
Expand Down
3 changes: 3 additions & 0 deletions examples/cloudnativepg/cnpg-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Cluster
metadata:
name: coder-db
namespace: coder
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
instances: 1
storage:
Expand Down
3 changes: 3 additions & 0 deletions examples/cloudnativepg/codercontrolplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: CoderControlPlane
metadata:
name: coder
namespace: coder
annotations:
argocd.argoproj.io/sync-wave: "2"
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
replicas: 1
service:
Expand Down