Skip to content

Commit 1369923

Browse files
committed
devops: add pgo kustomize
1 parent 7ea0174 commit 1369923

File tree

12 files changed

+255
-2
lines changed

12 files changed

+255
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

helm/install/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pgoControllerLeaseName: cpk-leader-election-lease
4949

5050
# replicas sets the number of PGO instances.
5151
# Warning: This should only be greater than 1 if pgoControllerLeaseName is set!
52-
replicas: 1
52+
replicas: 2
5353

5454
# imagePullSecretNames is a list of secret names to use for pulling controller images.
5555
# More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
@@ -88,4 +88,4 @@ resources:
8888
# Override environment variables entirely !!DANGEROUS!!
8989
# envOverride:
9090
# - name: PG_DEBUG
91-
# value: "true"
91+
# value: "true"

uc2c/kustomize/base/configmap.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: safety-advisor-pg-init-script-config
5+
data:
6+
init.sql: |
7+
-- Grant read-only access to existing and future tables
8+
GRANT CONNECT ON DATABASE safety_advisor TO appsmith;
9+
GRANT USAGE ON SCHEMA public TO appsmith;
10+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO appsmith;
11+
12+
-- Optional: write access to selected tables
13+
-- GRANT INSERT, UPDATE ON important_table TO appsmith;
14+
15+
-- Ensure all future tables are readable
16+
ALTER DEFAULT PRIVILEGES IN SCHEMA public
17+
GRANT SELECT ON TABLES TO appsmith;

uc2c/kustomize/base/job.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: safety-advisor-pg-init-script-job
5+
spec:
6+
template:
7+
spec:
8+
restartPolicy: Never
9+
containers:
10+
- name: psql
11+
image: postgres:16
12+
command: ["sh", "-c"]
13+
args:
14+
- |
15+
echo "Waiting for DB...";
16+
until pg_isready -h $PGHOST -p $PGPORT -U $PGUSER -d safety_advisor; do sleep 2; done;
17+
echo "Running init.sql...";
18+
psql -h $PGHOST -p $PGPORT -U $PGUSER -d safety_advisor -f /sql/init.sql
19+
env:
20+
- name: PGHOST
21+
valueFrom:
22+
secretKeyRef:
23+
name: safety-advisor-pg-pguser-postgres
24+
key: host
25+
- name: PGPORT
26+
valueFrom:
27+
secretKeyRef:
28+
name: safety-advisor-pg-pguser-postgres
29+
key: port
30+
- name: PGUSER
31+
valueFrom:
32+
secretKeyRef:
33+
name: safety-advisor-pg-pguser-postgres
34+
key: user
35+
- name: PGPASSWORD
36+
valueFrom:
37+
secretKeyRef:
38+
name: safety-advisor-pg-pguser-postgres
39+
key: password
40+
volumeMounts:
41+
- name: sql-script
42+
mountPath: /sql
43+
volumes:
44+
- name: sql-script
45+
configMap:
46+
name: safety-advisor-pg-init-script-config
47+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- postgrescluster.yaml
6+
- configmap.yaml
7+
- job.yaml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: safety-advisor-pg
5+
spec:
6+
postgresVersion: 16
7+
8+
instances:
9+
- name: primary
10+
replicas: 1
11+
dataVolumeClaimSpec:
12+
accessModes: ["ReadWriteOnce"]
13+
storageClassName: microk8s-hostpath
14+
resources:
15+
requests:
16+
storage: 8Gi
17+
resources:
18+
requests:
19+
cpu: "250m"
20+
memory: "512Mi"
21+
limits:
22+
cpu: "500m"
23+
memory: "1Gi"
24+
users:
25+
- name: postgres
26+
- name: safety-advisor
27+
databases: ["safety_advisor"]
28+
- name: appsmith
29+
databases: ["safety_advisor"]
30+
31+
patroni:
32+
dynamicConfiguration:
33+
postgresql:
34+
parameters:
35+
max_connections: "300"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: safety-advisor-ccps
4+
5+
resources:
6+
- ../../base
7+
8+
patches:
9+
- path: postgrescluster-patch.yaml
10+
target:
11+
group: postgres-operator.crunchydata.com
12+
version: v1beta1
13+
kind: PostgresCluster
14+
name: safety-advisor-pg
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: safety-advisor-pg
5+
spec:
6+
instances:
7+
- name: primary
8+
replicas: 1
9+
dataVolumeClaimSpec:
10+
accessModes: ["ReadWriteOnce"]
11+
storageClassName: microk8s-hostpath
12+
resources:
13+
requests:
14+
storage: 32Gi
15+
resources:
16+
requests:
17+
cpu: "500m"
18+
memory: "1Gi"
19+
limits:
20+
cpu: "1"
21+
memory: "2Gi"
22+
23+
patroni:
24+
dynamicConfiguration:
25+
postgresql:
26+
parameters:
27+
max_connections: "500"
28+
wal_level: replica
29+
archive_mode: "on"
30+
archive_timeout: "60s"
31+
32+
backups:
33+
pgbackrest:
34+
configuration:
35+
- secret:
36+
name: pgo-s3-creds
37+
global:
38+
repo1-path: /pgbackrest/crunchy-pg-operator/safety-advisor/safety-advisor-ccps
39+
repo1-retention-full: "14"
40+
repo1-retention-full-type: time
41+
repos:
42+
- name: repo1
43+
schedules:
44+
full: "0 1 * * 0"
45+
differential: "0 1 * * 1-6"
46+
s3:
47+
bucket: uc2civo
48+
endpoint: s3.amazonaws.com
49+
region: us-east-2
50+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: safety-advisor
4+
5+
resources:
6+
- ../../base
7+
8+
patches:
9+
- path: postgrescluster-patch.yaml
10+
target:
11+
group: postgres-operator.crunchydata.com
12+
version: v1beta1
13+
kind: PostgresCluster
14+
name: safety-advisor-pg
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: safety-advisor-pg
5+
spec:
6+
instances:
7+
- name: primary
8+
replicas: 1
9+
dataVolumeClaimSpec:
10+
accessModes: ["ReadWriteOnce"]
11+
storageClassName: microk8s-hostpath
12+
resources:
13+
requests:
14+
storage: 32Gi
15+
resources:
16+
requests:
17+
cpu: "500m"
18+
memory: "1Gi"
19+
limits:
20+
cpu: "1"
21+
memory: "2Gi"
22+
23+
patroni:
24+
dynamicConfiguration:
25+
postgresql:
26+
parameters:
27+
max_connections: "500"
28+
wal_level: replica
29+
archive_mode: "on"
30+
archive_timeout: "60s"
31+
32+
backups:
33+
pgbackrest:
34+
configuration:
35+
- secret:
36+
name: pgo-s3-creds
37+
global:
38+
repo1-path: /pgbackrest/crunchy-pg-operator/safety-advisor/safety-advisor-staging
39+
repo1-retention-full: "14"
40+
repo1-retention-full-type: time
41+
repos:
42+
- name: repo1
43+
schedules:
44+
full: "0 1 * * 0"
45+
differential: "0 1 * * 1-6"
46+
s3:
47+
bucket: uc2civo
48+
endpoint: s3.amazonaws.com
49+
region: us-east-2
50+

0 commit comments

Comments
 (0)