Skip to content

Commit 12818f8

Browse files
Merge pull request #262 from CodeForPhilly/docs/example-app
docs(guides): use a made-up example-app as the running example
2 parents ec21ba6 + 71fa177 commit 12818f8

6 files changed

Lines changed: 41 additions & 41 deletions

File tree

‎_docs/guides/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Read in order the first time; each page is short.
1414
- [Data and backups](database/data-and-backups.md): getting a `psql` shell, loading existing data, and what the backups do and don't give you.
1515
4. **[Reference](reference.md)**: the directory map and the gotchas, for when you already know the shape.
1616

17-
The running example is **paws-data-pipeline**, which is moving from a Postgres container inside its own pod to the shared cluster. Substitute your app's name.
17+
The running example is a made-up **example-app** that is moving from a Postgres container inside its own pod to the shared cluster. Substitute your app's name wherever you see it.
1818

1919
If you get stuck, ask in `#civic-cloud` on the Code for Philly Slack.

‎_docs/guides/database/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Both clusters run one PostgreSQL cluster for everyone, `shared-cluster` in the `
1515
2. **[Connect your app](connect.md)**: read host, database, user and password from configuration, for helm and for kustomize apps, and land the change in the right order.
1616
3. **[Data and backups](data-and-backups.md)**: get a `psql` shell, load existing data, and know what the shared backups do and don't cover.
1717

18-
The running example is `paws-data-pipeline`, moving from a Postgres container inside its own pod to the shared cluster. Substitute your app's name.
18+
The running example is a made-up `example-app` with a Postgres user and database both named `example`. Substitute your app's name.

‎_docs/guides/database/connect.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Once [provisioned](provision.md), your app needs five things: host, port, databa
55
```
66
host shared-cluster-rw.cloudnative-pg.svc.cluster.local (-ro for a read replica)
77
port 5432
8-
database paws
9-
user paws
10-
password Secret paws-db-credentials, key "password"
8+
database example
9+
user example
10+
password Secret example-db-credentials, key "password"
1111
```
1212

1313
## Helm apps
@@ -31,17 +31,17 @@ env:
3131
```
3232
{% endraw %}
3333
34-
If the chart currently runs its own Postgres container (PAWS did, as a sidecar in the app pod), remove it, or keep it behind a `database.embedded: true` default so local dev is unchanged. Cut a release and bump `.holo/sources/<app>.toml` to the new tag.
34+
If the chart currently runs its own Postgres container (a common starting point: a sidecar in the app pod, or a subchart), remove it, or keep it behind a `database.embedded: true` default so local dev is unchanged. Cut a release and bump `.holo/sources/<app>.toml` to the new tag.
3535

36-
Then set the values in the cluster repo, `paws-data-pipeline/release-values.yaml`:
36+
Then set the values in the cluster repo, `example-app/release-values.yaml`:
3737

3838
```yaml
3939
database:
4040
embedded: false
4141
host: shared-cluster-rw.cloudnative-pg.svc.cluster.local
42-
name: paws
43-
user: paws
44-
passwordSecret: paws-db-credentials
42+
name: example
43+
user: example
44+
passwordSecret: example-db-credentials
4545
```
4646

4747
## Kustomize apps

‎_docs/guides/database/data-and-backups.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
Your team's access covers your namespace, not `cloudnative-pg`, so the way in is a throwaway pod in your namespace with the credentials loaded:
66

77
```bash
8-
kubectl -n paws-data-pipeline run psql --rm -it --restart=Never --image=postgres:18 \
8+
kubectl -n example-app run psql --rm -it --restart=Never --image=postgres:18 \
99
--overrides='{"spec":{"containers":[{"name":"psql","image":"postgres:18","stdin":true,"tty":true,
1010
"command":["psql"],
1111
"env":[{"name":"PGHOST","value":"shared-cluster-rw.cloudnative-pg.svc.cluster.local"},
12-
{"name":"PGDATABASE","value":"paws"},
13-
{"name":"PGUSER","valueFrom":{"secretKeyRef":{"name":"paws-db-credentials","key":"username"}}},
14-
{"name":"PGPASSWORD","valueFrom":{"secretKeyRef":{"name":"paws-db-credentials","key":"password"}}}]}]}}'
12+
{"name":"PGDATABASE","value":"example"},
13+
{"name":"PGUSER","valueFrom":{"secretKeyRef":{"name":"example-db-credentials","key":"username"}}},
14+
{"name":"PGPASSWORD","valueFrom":{"secretKeyRef":{"name":"example-db-credentials","key":"password"}}}]}]}}'
1515
```
1616

1717
The same pod with `["sleep","3600"]` as the command is a workbench for `pg_dump` and `pg_restore`; `kubectl cp` files in and out.
@@ -24,9 +24,9 @@ Dump the old database in custom format, then restore **as your own user**, so yo
2424
# from wherever can reach the old database
2525
pg_dump -Fc --no-owner --no-privileges -h OLDHOST -U OLDUSER -d OLDDB -f app.dump
2626

27-
# from the workbench pod, connected as paws
27+
# from the workbench pod, connected as example
2828
pg_restore -l app.dump | grep -vE " (EXTENSION|COMMENT - EXTENSION) " > list
29-
pg_restore --no-owner --no-privileges -L list -d paws app.dump
29+
pg_restore --no-owner --no-privileges -L list -d example app.dump
3030
```
3131

3232
The `grep -v EXTENSION` matters: the dump wants to `CREATE EXTENSION`, your user can't, and the extension already exists from `database.yaml`. For a 50 MB database this takes seconds.

‎_docs/guides/database/provision.md‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Your Postgres user needs a password. cnpg reads it from a Secret in `cloudnative
99
Run this with `KUBECONFIG` pointing at the cluster you're adding to (sandbox first); sealed values only decrypt on the cluster that sealed them.
1010

1111
```bash
12-
APP=paws-data-pipeline; ROLE=paws
12+
APP=example-app; ROLE=example
1313
PW=$(openssl rand -base64 48 | tr -dc A-Za-z0-9 | head -c 40)
1414
for ns in cloudnative-pg $APP; do
1515
kubectl create secret generic $ROLE-db-credentials -n $ns \
@@ -22,42 +22,42 @@ done
2222
unset PW
2323
```
2424

25-
That writes `cloudnative-pg.secrets/paws-db-credentials.yaml` and `paws-data-pipeline.secrets/paws-db-credentials.yaml`. You never need to write the password down; once deployed, anyone with access to your namespace can read it back from the Secret.
25+
That writes `cloudnative-pg.secrets/example-db-credentials.yaml` and `example-app.secrets/example-db-credentials.yaml`. You never need to write the password down; once deployed, anyone with access to your namespace can read it back from the Secret.
2626

27-
## 2. The user: `paws-data-pipeline.cnpg/role.yaml`
27+
## 2. The user: `example-app.cnpg/role.yaml`
2828

2929
A `DatabaseRole` is your Postgres user. cnpg creates it on `shared-cluster` and keeps it matching this spec, password included.
3030

3131
```yaml
3232
apiVersion: postgresql.cnpg.io/v1
3333
kind: DatabaseRole
3434
metadata:
35-
name: paws
35+
name: example
3636
namespace: cloudnative-pg # required: cnpg wants this next to the Cluster
3737
spec:
3838
cluster:
3939
name: shared-cluster
40-
name: paws
40+
name: example
4141
login: true
4242
connectionLimit: 20 # the cluster allows 100 in total; be a good neighbour
4343
passwordSecret:
44-
name: paws-db-credentials
44+
name: example-db-credentials
4545
databaseRoleReclaimPolicy: retain # deleting this file does not drop the role
4646
```
4747
48-
## 3. The database: `paws-data-pipeline.cnpg/database.yaml`
48+
## 3. The database: `example-app.cnpg/database.yaml`
4949

5050
```yaml
5151
apiVersion: postgresql.cnpg.io/v1
5252
kind: Database
5353
metadata:
54-
name: paws
54+
name: example
5555
namespace: cloudnative-pg
5656
spec:
5757
cluster:
5858
name: shared-cluster
59-
name: paws
60-
owner: paws
59+
name: example
60+
owner: example
6161
extensions: # only if you need them
6262
- name: postgis
6363
ensure: present
@@ -73,11 +73,11 @@ Commit the four files, run the projection diff ([how](../how-deploys-work.md#see
7373
Then check it took:
7474

7575
```bash
76-
kubectl -n cloudnative-pg get databaserole paws -o jsonpath='{.status}'
77-
kubectl -n cloudnative-pg get database paws -o jsonpath='{.status.applied}{"\n"}'
76+
kubectl -n cloudnative-pg get databaserole example -o jsonpath='{.status}'
77+
kubectl -n cloudnative-pg get database example -o jsonpath='{.status.applied}{"\n"}'
7878
```
7979

80-
You now have an empty database named `paws`, owned by a user named `paws`, reachable from inside the cluster at `shared-cluster-rw.cloudnative-pg.svc.cluster.local`. Nothing uses it yet.
80+
You now have an empty database named `example`, owned by a user named `example`, reachable from inside the cluster at `shared-cluster-rw.cloudnative-pg.svc.cluster.local`. Nothing uses it yet.
8181

8282
!!! warning "Secret before role"
8383
If cnpg reconciles the `DatabaseRole` before its Secret exists, it marks the role failed and does not retry on its own. Landing both in one PR is enough. If it happens anyway: `kubectl annotate cluster -n cloudnative-pg shared-cluster cnpg.io/reconciliationLoop="$(date +%s)" --overwrite`, and check `.status` again.

‎_docs/guides/your-project-in-the-repo.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Your project in the repo
22

3-
A project is a small set of files in predictable places. Here they are for `paws-data-pipeline`; yours look the same with the name swapped.
3+
A project is a small set of files in predictable places. Here they are for a made-up `example-app`; yours look the same with the name swapped.
44

55
```
6-
.holo/sources/paws-data-pipeline.toml ← where your code comes from, pinned to a tag
7-
.holo/branches/k8s-manifests/paws-data-pipeline/helm-chart.toml
8-
.holo/lenses/paws-data-pipeline.toml ← how it's rendered (helm or kustomize)
9-
paws-data-pipeline/release-values.yaml ← your helm values (or kustomization.yaml)
10-
paws-data-pipeline.secrets/*.yaml ← SealedSecrets for your namespace
11-
paws-data-pipeline.cnpg/*.yaml ← your database user + database (next page)
12-
_gateways/paws-data-pipeline.yaml ← your public hostname and TLS
13-
_admins/paws-data-pipeline.yaml ← namespace + a deployment-admin role for your team
6+
.holo/sources/example-app.toml ← where your code comes from, pinned to a tag
7+
.holo/branches/k8s-manifests/example-app/helm-chart.toml
8+
.holo/lenses/example-app.toml ← how it's rendered (helm or kustomize)
9+
example-app/release-values.yaml ← your helm values (or kustomization.yaml)
10+
example-app.secrets/*.yaml ← SealedSecrets for your namespace
11+
example-app.cnpg/*.yaml ← your database user + database (next page)
12+
_gateways/example-app.yaml ← your public hostname and TLS
13+
_admins/example-app.yaml ← namespace + a deployment-admin role for your team
1414
```
1515

1616
## What you own
@@ -21,15 +21,15 @@ Directories starting with `_` (`_infra/`, `_gateways/`, `_admins/`) are cluster-
2121

2222
## The one rule about `<app>/`
2323

24-
`paws-data-pipeline/` is the **input to a lens**. For a helm app that means: the chart is fetched into it from your repo, `release-values.yaml` is applied, and the rendered output *replaces* the directory in the projected tree. Anything else you put in that directory is not rendered and silently disappears.
24+
`example-app/` is the **input to a lens**. For a helm app that means: the chart is fetched into it from your repo, `release-values.yaml` is applied, and the rendered output *replaces* the directory in the projected tree. Anything else you put in that directory is not rendered and silently disappears.
2525

26-
That's why things that belong to your app but aren't part of the chart live in **sibling directories** with a suffix: `paws-data-pipeline.secrets/` and `paws-data-pipeline.cnpg/`. Those are raw manifests, applied as written, and routed to the right namespace by the `namespace:` they declare.
26+
That's why things that belong to your app but aren't part of the chart live in **sibling directories** with a suffix: `example-app.secrets/` and `example-app.cnpg/`. Those are raw manifests, applied as written, and routed to the right namespace by the `namespace:` they declare.
2727

2828
(A kustomize app can get away with a subdirectory instead, because kustomize passes raw resources through; balancer keeps its database files in `balancer/cnpg/` and lists them in its kustomization. Either way is fine; the sibling directory works for both.)
2929

3030
## Pins
3131

32-
`.holo/sources/paws-data-pipeline.toml` names a git ref in your repo. **Make it a tag.** Tracking `refs/heads/master` means a merge in your repo can change what's deployed, or break the cluster build, with no PR here to review it. Cut a release, bump the pin, open the PR: that's a deploy.
32+
`.holo/sources/example-app.toml` names a git ref in your repo. **Make it a tag.** Tracking `refs/heads/master` means a merge in your repo can change what's deployed, or break the cluster build, with no PR here to review it. Cut a release, bump the pin, open the PR: that's a deploy.
3333

3434
## Your namespace
3535

0 commit comments

Comments
 (0)