Skip to content

Commit 0c20858

Browse files
authored
Replace CrunchyDB (bcgov#2379)
1 parent 8e13fc6 commit 0c20858

File tree

26 files changed

+263
-80
lines changed

26 files changed

+263
-80
lines changed

db/postgres/docker/Dockerfile.prod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM postgres:15.6
2+
3+
COPY ./scripts /docker-entrypoint-initdb.d/

openshift/kustomize/api-services/base/deploy.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ spec:
7070
- name: ingest-storage
7171
mountPath: /mnt/ingest
7272
resources:
73-
limits:
74-
cpu: 500m
75-
memory: 1536Mi
7673
requests:
7774
cpu: 100m
7875
memory: 350Mi
@@ -140,13 +137,13 @@ spec:
140137
- name: DB_POSTGRES_USERNAME
141138
valueFrom:
142139
secretKeyRef:
143-
name: crunchy-pguser-admin
144-
key: user
140+
name: database
141+
key: USERNAME
145142
- name: DB_POSTGRES_PASSWORD
146143
valueFrom:
147144
secretKeyRef:
148-
name: crunchy-pguser-admin
149-
key: password
145+
name: database
146+
key: PASSWORD
150147

151148
- name: Elastic__Url
152149
valueFrom:
@@ -179,7 +176,7 @@ spec:
179176
configMapKeyRef:
180177
name: reporting-shared
181178
key: REPORTING_REQUEST_TRANSCRIPT_URL
182-
179+
183180
# S3 Configuration
184181
- name: S3_ACCESS_KEY
185182
valueFrom:

openshift/kustomize/api/base/deploy.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ spec:
7070
- name: ingest-storage
7171
mountPath: /mnt/ingest
7272
resources:
73-
limits:
74-
cpu: 500m
75-
memory: 1536Mi
7673
requests:
7774
cpu: 100m
7875
memory: 350Mi
@@ -137,13 +134,13 @@ spec:
137134
- name: DB_POSTGRES_USERNAME
138135
valueFrom:
139136
secretKeyRef:
140-
name: crunchy-pguser-admin
141-
key: user
137+
name: database
138+
key: USERNAME
142139
- name: DB_POSTGRES_PASSWORD
143140
valueFrom:
144141
secretKeyRef:
145-
name: crunchy-pguser-admin
146-
key: password
142+
name: database
143+
key: PASSWORD
147144

148145
- name: Elastic__Url
149146
valueFrom:
@@ -176,7 +173,7 @@ spec:
176173
configMapKeyRef:
177174
name: reporting-shared
178175
key: REPORTING_REQUEST_TRANSCRIPT_URL
179-
176+
180177
# S3 Configuration
181178
- name: S3_ACCESS_KEY
182179
valueFrom:

openshift/kustomize/api/base/statefulset.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ spec:
8686
- name: ingest-storage
8787
mountPath: /mnt/ingest
8888
resources:
89-
limits:
90-
cpu: 500m
91-
memory: 1536Mi
9289
requests:
9390
cpu: 100m
9491
memory: 350Mi
@@ -150,13 +147,13 @@ spec:
150147
- name: DB_POSTGRES_USERNAME
151148
valueFrom:
152149
secretKeyRef:
153-
name: crunchy-pguser-admin
154-
key: user
150+
name: database
151+
key: USERNAME
155152
- name: DB_POSTGRES_PASSWORD
156153
valueFrom:
157154
secretKeyRef:
158-
name: crunchy-pguser-admin
159-
key: password
155+
name: database
156+
key: PASSWORD
160157

161158
- name: Elastic__Url
162159
valueFrom:

openshift/kustomize/elastic/base/statefulset.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ spec:
6363
requests:
6464
cpu: 100m
6565
memory: 850Mi
66-
limits:
67-
cpu: 200m
68-
memory: 1500Mi
6966
ports:
7067
- containerPort: 9200
7168
name: 9200-tcp

openshift/kustomize/kafka/broker/base/statefulset.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ spec:
8181
requests:
8282
cpu: 50m
8383
memory: 3Gi
84-
limits:
85-
cpu: 100m
86-
memory: 5Gi
8784
terminationMessagePath: /dev/termination-log
8885
terminationMessagePolicy: File
8986
env:

openshift/kustomize/postgres/crunchy/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ To install the CrunchyDB HA Cluster in the **dev** namespace, run the following
1111
To perform an adhoc backup of the database run the following command.
1212

1313
```bash
14-
oc annotate -n 9b301c-test postgrescluster postgres-cluster \
14+
oc annotate -n 9b301c-prod postgrescluster crunchy \
1515
postgres-operator.crunchydata.com/pgbackrest-backup="$( date '+%F_%H:%M:%S' )"
1616
```
1717

1818
Subsequent runs will require the `--overwrite` attribute.
1919

2020
```bash
21-
oc annotate -n 9b301c-test postgrescluster postgres-cluster --overwrite \
21+
oc annotate -n 9b301c-prod postgrescluster crunchy --overwrite \
2222
postgres-operator.crunchydata.com/pgbackrest-backup="$( date '+%F_%H:%M:%S' )"
2323
```
2424

@@ -56,7 +56,7 @@ oc kustomize openshift/kustomize/postgres/crunchy/overlays/dev | oc apply -f -
5656
You will need to wait and confirm the backup has been completed, as this is just a request for it do it when it can.
5757

5858
```bash
59-
oc annotate -n 9b301c-test postgrescluster postgres-cluster \
59+
oc annotate -n 9b301c-test postgrescluster crunchy \
6060
postgres-operator.crunchydata.com/pgbackrest-backup="$( date '+%F_%H:%M:%S' )"
6161
```
6262

@@ -79,32 +79,32 @@ Link the cluster to the update.
7979
8080
```bash
8181
# Annotate the cluster
82-
oc -n 9b301c-dev annotate postgrescluster crunchy postgres-operator.crunchydata.com/allow-upgrade="crunchy-upgrade"
82+
oc -n 9b301c-prod annotate postgrescluster crunchy postgres-operator.crunchydata.com/allow-upgrade="crunchy-upgrade"
8383
```
8484

8585
Shutdown the cluster.
8686

8787
```bash
88-
oc patch postgrescluster/crunchy -n 9b301c-dev --type merge --patch '{"spec":{"shutdown": true}}'
88+
oc patch postgrescluster/crunchy -n 9b301c-prod --type merge --patch '{"spec":{"shutdown": true}}'
8989
```
9090

9191
### Step 6: Watch and Wait
9292

9393
Check on status.
9494

9595
```bash
96-
oc describe pgupgrade -n 9b301c-dev
96+
oc describe pgupgrade -n 9b301c-prod
9797
```
9898

9999
### Step 7: Restart
100100

101101
Update `PostgresCluster` object with `spec.postgresVersion: 15`.
102102

103103
```bash
104-
oc patch postgrescluster/crunchy -n 9b301c-dev --type merge --patch '{"spec":{"postgresVersion": 15}}'
104+
oc patch postgrescluster/crunchy -n 9b301c-prod --type merge --patch '{"spec":{"postgresVersion": 15}}'
105105

106106
# Start up again
107-
oc patch postgrescluster/crunchy -n 9b301c-dev --type merge --patch '{"spec":{"shutdown": false}}'
107+
oc patch postgrescluster/crunchy -n 9b301c-prod --type merge --patch '{"spec":{"shutdown": false}}'
108108
```
109109

110110
### Other Commands
@@ -114,3 +114,9 @@ If you need to restart.
114114
```bash
115115
oc patch postgrescluster/crunchy -n 9b301c-dev --type merge --patch '{"spec":{"metadata":{"annotations":{"restarted":"'"$(date)"'"}}}}'
116116
```
117+
118+
### Restore
119+
120+
```bash
121+
oc annotate -n 9b301c-dev postgrescluster crunchy --overwrite postgres-operator.crunchydata.com/pgbackrest-restore="$(date)"
122+
```

openshift/kustomize/postgres/crunchy/base/deploy.yaml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ metadata:
1111
component: postgres
1212
managed-by: kustomize
1313
created-by: jeremy.foster
14-
updated-by: kulpree
1514
spec:
16-
postgresVersion: 14
15+
postgresVersion: 15
1716
users:
1817
- name: postgres
1918
- name: admin
@@ -26,19 +25,13 @@ spec:
2625
requests:
2726
cpu: 25m
2827
memory: 100Mi
29-
limits:
30-
cpu: 50m
31-
memory: 250Mi
3228
instances:
3329
- name: postgres
3430
replicas: 3
3531
resources:
3632
requests:
3733
cpu: 50m
3834
memory: 250Mi
39-
limits:
40-
cpu: 250m
41-
memory: 2Gi
4235
dataVolumeClaimSpec:
4336
accessModes:
4437
- ReadWriteOnce
@@ -69,21 +62,21 @@ spec:
6962
requests:
7063
cpu: 25m
7164
memory: 100Mi
72-
limits:
73-
cpu: 100m
74-
memory: 250Mi
7565
backups:
7666
pgbackrest:
67+
# restore:
68+
# enabled: true
69+
# repoName: repo1
70+
# options:
71+
# - --type=time
72+
# - --target="2024-01-04 12:00:00-00"
7773
global:
7874
repo1-retention-full: "1"
7975
repoHost:
8076
resources:
8177
requests:
8278
cpu: 50m
8379
memory: 100Mi
84-
limits:
85-
cpu: 250m
86-
memory: 1Gi
8780
jobs:
8881
ttlSecondsAfterFinished: 100
8982
repos:
@@ -111,17 +104,11 @@ spec:
111104
requests:
112105
cpu: 50m
113106
memory: 50Mi
114-
limits:
115-
cpu: 250m
116-
memory: 500Mi
117107
pgbackrestConfig:
118108
resources:
119109
requests:
120110
cpu: 25m
121111
memory: 50Mi
122-
limits:
123-
cpu: 100m
124-
memory: 500Mi
125112
proxy:
126113
pgBouncer:
127114
config:
@@ -132,9 +119,6 @@ spec:
132119
requests:
133120
cpu: 25m
134121
memory: 100Mi
135-
limits:
136-
cpu: 50m
137-
memory: 250Mi
138122
affinity:
139123
podAntiAffinity:
140124
preferredDuringSchedulingIgnoredDuringExecution:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PGUpgrade
3+
metadata:
4+
name: crunchy-upgrade
5+
spec:
6+
postgresClusterName: crunchy
7+
fromPostgresVersion: 14
8+
toPostgresVersion: 15

openshift/kustomize/postgres/crunchy/overlays/prod/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ patches:
1616
value: 3
1717
- op: replace
1818
path: /spec/instances/0/dataVolumeClaimSpec/resources/requests/storage
19-
value: 28Gi
19+
value: 37Gi
2020
path: /spec/backups/pgbackrest/repos/0/volume/volumeClaimSpec/resources/requests/storage
2121
value: 65Gi

0 commit comments

Comments
 (0)