You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 12818f8
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: _docs/guides/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,6 @@ Read in order the first time; each page is short.
14
14
-[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.
15
15
4.**[Reference](reference.md)**: the directory map and the gotchas, for when you already know the shape.
16
16
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.
18
18
19
19
If you get stuck, ask in `#civic-cloud` on the Code for Philly Slack.
Copy file name to clipboardExpand all lines: _docs/guides/database/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,4 +15,4 @@ Both clusters run one PostgreSQL cluster for everyone, `shared-cluster` in the `
15
15
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.
16
16
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.
17
17
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.
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.
35
35
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`:
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
30
30
```
31
31
32
32
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.
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.
26
26
27
-
## 2. The user: `paws-data-pipeline.cnpg/role.yaml`
27
+
## 2. The user: `example-app.cnpg/role.yaml`
28
28
29
29
A `DatabaseRole` is your Postgres user. cnpg creates it on `shared-cluster` and keeps it matching this spec, password included.
30
30
31
31
```yaml
32
32
apiVersion: postgresql.cnpg.io/v1
33
33
kind: DatabaseRole
34
34
metadata:
35
-
name: paws
35
+
name: example
36
36
namespace: cloudnative-pg # required: cnpg wants this next to the Cluster
37
37
spec:
38
38
cluster:
39
39
name: shared-cluster
40
-
name: paws
40
+
name: example
41
41
login: true
42
42
connectionLimit: 20# the cluster allows 100 in total; be a good neighbour
43
43
passwordSecret:
44
-
name: paws-db-credentials
44
+
name: example-db-credentials
45
45
databaseRoleReclaimPolicy: retain # deleting this file does not drop the role
46
46
```
47
47
48
-
## 3. The database: `paws-data-pipeline.cnpg/database.yaml`
48
+
## 3. The database: `example-app.cnpg/database.yaml`
49
49
50
50
```yaml
51
51
apiVersion: postgresql.cnpg.io/v1
52
52
kind: Database
53
53
metadata:
54
-
name: paws
54
+
name: example
55
55
namespace: cloudnative-pg
56
56
spec:
57
57
cluster:
58
58
name: shared-cluster
59
-
name: paws
60
-
owner: paws
59
+
name: example
60
+
owner: example
61
61
extensions: # only if you need them
62
62
- name: postgis
63
63
ensure: present
@@ -73,11 +73,11 @@ Commit the four files, run the projection diff ([how](../how-deploys-work.md#see
73
73
Then check it took:
74
74
75
75
```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"}'
78
78
```
79
79
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.
81
81
82
82
!!! warning "Secret before role"
83
83
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.
.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
14
14
```
15
15
16
16
## What you own
@@ -21,15 +21,15 @@ Directories starting with `_` (`_infra/`, `_gateways/`, `_admins/`) are cluster-
21
21
22
22
## The one rule about `<app>/`
23
23
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.
25
25
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.
27
27
28
28
(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.)
29
29
30
30
## Pins
31
31
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.
0 commit comments