Skip to content

Commit 92eec3b

Browse files
Update backup schedules and retention
1 parent fe15a53 commit 92eec3b

File tree

10 files changed

+536
-174
lines changed

10 files changed

+536
-174
lines changed

infrastructure/crunchy-db/Chart.lock

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
apiVersion: v2
2-
name: biohub-platform-crunchy-db
3-
description: A Helm chart for Biohub Crunchy Postgres Cluster (DEV/TEST/PROD only)
2+
appVersion: 5.5.1
3+
description: A Helm chart for BioHub Crunchy Postgres Cluster (DEV/TEST/PROD only), based on the BCGov Crunchy Postgres Helm chart.
4+
name: crunchy-postgres
45
type: application
56
version: 0.1.0
6-
appVersion: "1.0.0"
7-
8-
dependencies:
9-
- name: crunchy-postgres
10-
version: 0.6.6
11-
repository: https://bcgov.github.io/crunchy-postgres/
7+
appVersion: "1.0.0"
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: {{ template "crunchy-postgres.fullname" . }}
5+
labels: {{ include "crunchy-postgres.labels" . | nindent 4 }}
6+
spec:
7+
openshift: {{ .Values.openshift }}
8+
metadata:
9+
labels: {{ include "crunchy-postgres.labels" . | nindent 6 }}
10+
{{ if .Values.crunchyImage }}
11+
image: {{ .Values.crunchyImage }}
12+
{{ end }}
13+
imagePullPolicy: {{.Values.imagePullPolicy}}
14+
postgresVersion: {{ .Values.postgresVersion }}
15+
{{ if .Values.postGISVersion }}
16+
postGISVersion: {{ .Values.postGISVersion | quote }}
17+
{{ end }}
18+
postgresVersion: {{ .Values.postgresVersion }}
19+
20+
{{ if .Values.pgmonitor.enabled }}
21+
22+
monitoring:
23+
pgmonitor:
24+
# this stuff is for the "exporter" container in the "postgres-cluster-ha" set of pods
25+
exporter:
26+
{{ if .Values.pgmonitor.exporter.image}}
27+
image: {{ .Values.pgmonitor.exporter.image}}
28+
{{ end }}
29+
resources:
30+
requests:
31+
cpu: {{ .Values.pgmonitor.exporter.requests.cpu }}
32+
memory: {{ .Values.pgmonitor.exporter.requests.memory }}
33+
{{ if .Values.pgmonitor.exporter.limits }}
34+
limits:
35+
cpu: {{ .Values.pgmonitor.exporter.limits.cpu }}
36+
memory: {{ .Values.pgmonitor.exporter.limits.memory }}
37+
{{ end }}
38+
39+
{{ end }}
40+
41+
instances:
42+
- name: {{ .Values.instances.name }}
43+
replicas: {{ .Values.instances.replicas }}
44+
resources:
45+
requests:
46+
cpu: {{ .Values.instances.requests.cpu }}
47+
memory: {{ .Values.instances.requests.memory }}
48+
{{ if .Values.instances.limits }}
49+
limits:
50+
cpu: {{ .Values.instances.limits.cpu }}
51+
memory: {{ .Values.instances.limits.memory }}
52+
{{ end }}
53+
sidecars:
54+
replicaCertCopy:
55+
resources:
56+
requests:
57+
cpu: {{ .Values.instances.replicaCertCopy.requests.cpu }}
58+
memory: {{ .Values.instances.replicaCertCopy.requests.memory }}
59+
{{ if .Values.instances.replicaCertCopy.limits }}
60+
limits:
61+
cpu: {{ .Values.instances.replicaCertCopy.limits.cpu }}
62+
memory: {{ .Values.instances.replicaCertCopy.limits.memory }}
63+
{{ end }}
64+
dataVolumeClaimSpec:
65+
accessModes:
66+
- "ReadWriteOnce"
67+
resources:
68+
requests:
69+
storage: {{ .Values.instances.dataVolumeClaimSpec.storage }}
70+
storageClassName: {{ .Values.instances.dataVolumeClaimSpec.storageClassName }}
71+
affinity:
72+
podAntiAffinity:
73+
preferredDuringSchedulingIgnoredDuringExecution:
74+
- weight: 1
75+
podAffinityTerm:
76+
topologyKey: topology.kubernetes.io/zone
77+
labelSelector:
78+
matchLabels:
79+
postgres-operator.crunchydata.com/cluster:
80+
{{ template "crunchy-postgres.fullname" . }}
81+
postgres-operator.crunchydata.com/instance-set: {{ .Values.instances.name }}-ha
82+
83+
users:
84+
- name: {{ template "crunchy-postgres.fullname" . }}
85+
databases:
86+
- {{ template "crunchy-postgres.fullname" . }}
87+
options: "CREATEROLE"
88+
- name: postgres
89+
databases:
90+
- {{ template "crunchy-postgres.fullname" . }}
91+
92+
{{ if .Values.dataSource.enabled }}
93+
dataSource:
94+
pgbackrest:
95+
configuration:
96+
- secret:
97+
name: {{ .Values.dataSource.secretName }}
98+
global:
99+
{{ .Values.dataSource.repo.name }}-path: {{ .Values.dataSource.repo.path | quote }}
100+
repo:
101+
name: {{ .Values.dataSource.repo.name }}
102+
s3:
103+
bucket: {{ .Values.dataSource.repo.s3.bucket }}
104+
endpoint: {{ .Values.dataSource.repo.s3.endpoint }}
105+
region: {{ .Values.dataSource.repo.s3.region }}
106+
stanza: {{ .Values.dataSource.stanza }}
107+
{{ end }}
108+
109+
backups:
110+
pgbackrest:
111+
{{ if .Values.pgBackRest.image }}
112+
image: {{ .Values.pgBackRest.image }}
113+
{{ end }}
114+
configuration:
115+
- secret:
116+
name: {{ .Values.pgBackRest.s3.s3Secret }}
117+
global:
118+
{{- range .Values.pgBackRest.repos }}
119+
{{ .name }}-path: {{ .path | quote }}
120+
{{ .name }}-retention-full: {{ .retention | quote }}
121+
{{ .name }}-retention-full-type: {{ .retentionFullType }}
122+
{{ .name }}-s3-uri-style: {{ $.Values.pgBackRest.s3.s3UriStyle }}
123+
{{- end }}
124+
repos:
125+
{{- range .Values.pgBackRest.repos }}
126+
- name: {{ .name }}
127+
schedules:
128+
full: {{ .fullSchedule | quote }}
129+
s3:
130+
bucket: {{ $.Values.pgBackRest.s3.bucket }}
131+
endpoint: {{ $.Values.pgBackRest.s3.endpoint }}
132+
region: {{ $.Values.pgBackRest.s3.region }}
133+
{{- end }}
134+
# this stuff is for the "pgbackrest" container (the only non-init container) in the "postgres-crunchy-repo-host" pod
135+
repoHost:
136+
resources:
137+
requests:
138+
cpu: {{ .Values.pgBackRest.repoHost.requests.cpu }}
139+
memory: {{ .Values.pgBackRest.repoHost.requests.memory }}
140+
{{- if .Values.pgBackRest.repoHost.limits }}
141+
limits:
142+
cpu: {{ .Values.pgBackRest.repoHost.limits.cpu }}
143+
memory: {{ .Values.pgBackRest.repoHost.limits.memory }}
144+
{{- end }}
145+
sidecars:
146+
# this stuff is for the "pgbackrest" container in the "postgres-crunchy-ha" set of pods
147+
pgbackrest:
148+
resources:
149+
requests:
150+
cpu: {{ .Values.pgBackRest.sidecars.requests.cpu }}
151+
memory: {{ .Values.pgBackRest.sidecars.requests.memory }}
152+
{{- if .Values.pgBackRest.sidecars.limits }}
153+
limits:
154+
cpu: {{ .Values.pgBackRest.sidecars.limits.cpu }}
155+
memory: {{ .Values.pgBackRest.sidecars.limits.memory }}
156+
{{- end }}
157+
pgbackrestConfig:
158+
resources:
159+
requests:
160+
cpu: {{ .Values.pgBackRest.sidecars.requests.cpu }}
161+
memory: {{ .Values.pgBackRest.sidecars.requests.memory }}
162+
{{- if .Values.pgBackRest.sidecars.limits }}
163+
limits:
164+
cpu: {{ .Values.pgBackRest.sidecars.limits.cpu }}
165+
memory: {{ .Values.pgBackRest.sidecars.limits.memory }}
166+
{{- end }}
167+
standby:
168+
enabled: {{ .Values.standby.enabled }}
169+
repoName: {{ .Values.standby.repoName }}
170+
171+
patroni:
172+
dynamicConfiguration:
173+
postgresql:
174+
pg_hba:
175+
- {{ .Values.patroni.postgresql.pg_hba}}
176+
parameters:
177+
shared_buffers: {{ .Values.patroni.postgresql.parameters.shared_buffers }}
178+
wal_buffers: {{ .Values.patroni.postgresql.parameters.wal_buffers }}
179+
min_wal_size: {{ .Values.patroni.postgresql.parameters.min_wal_size }}
180+
max_wal_size: {{ .Values.patroni.postgresql.parameters.max_wal_size }}
181+
max_slot_wal_keep_size: {{ .Values.patroni.postgresql.parameters.max_slot_wal_keep_size }}
182+
183+
proxy:
184+
pgBouncer:
185+
config:
186+
global:
187+
client_tls_sslmode: disable
188+
{{ if .Values.proxy.pgBouncer.image }}
189+
image: {{ .Values.proxy.pgBouncer.image }}
190+
{{ end }}
191+
replicas: {{ .Values.proxy.pgBouncer.replicas }}
192+
# these resources are for the "pgbouncer" container in the "postgres-crunchy-ha-pgbouncer" set of pods
193+
# there is a sidecar in these pods which are not mentioned here, but the requests/limits are teeny weeny by default so no worries there.
194+
resources:
195+
requests:
196+
cpu: {{ .Values.proxy.pgBouncer.requests.cpu }}
197+
memory: {{ .Values.proxy.pgBouncer.requests.memory }}
198+
{{ if .Values.proxy.pgBouncer.limits }}
199+
limits:
200+
cpu: {{ .Values.proxy.pgBouncer.limits.cpu }}
201+
memory: {{ .Values.proxy.pgBouncer.limits.memory }}
202+
{{ end }}
203+
affinity:
204+
podAntiAffinity:
205+
preferredDuringSchedulingIgnoredDuringExecution:
206+
- weight: 1
207+
podAffinityTerm:
208+
topologyKey: topology.kubernetes.io/zone
209+
labelSelector:
210+
matchLabels:
211+
postgres-operator.crunchydata.com/cluster:
212+
{{ template "crunchy-postgres.fullname" . }}
213+
postgres-operator.crunchydata.com/role: pgbouncer
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "crunchy-postgres.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "crunchy-postgres.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "crunchy-postgres.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "crunchy-postgres.labels" -}}
37+
helm.sh/chart: {{ include "crunchy-postgres.chart" . }}
38+
{{ include "crunchy-postgres.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "crunchy-postgres.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "crunchy-postgres.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "crunchy-postgres.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "crunchy-postgres.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{/* Output S3 credential lines for one repo (index 0 = repo1, 1 = repo2, ...). */}}
2+
{{- define "postgres.s3" }}
3+
{{- if .s3 }}
4+
{{- if .s3.key }}
5+
repo{{ add .index 1 }}-s3-key={{ .s3.key }}
6+
{{- end }}
7+
{{- if .s3.keySecret }}
8+
repo{{ add .index 1 }}-s3-key-secret={{ .s3.keySecret }}
9+
{{- end }}
10+
{{- if .s3.keyType }}
11+
repo{{ add .index 1 }}-s3-key-type={{ .s3.keyType }}
12+
{{- end }}
13+
{{- if .s3.encryptionPassphrase }}
14+
repo{{ add .index 1 }}-cipher-pass={{ .s3.encryptionPassphrase }}
15+
{{- end }}
16+
{{- end }}
17+
{{- end }}
18+
19+
{{/* Full S3 config for all four repos (repo1-repo4). Pass root context (.). */}}
20+
{{- define "postgres.s3.full" -}}
21+
[global]
22+
{{- $root := . }}
23+
{{- range $i := until 4 }}
24+
{{ include "postgres.s3" (dict "s3" $root.Values.pgBackRest.s3 "index" $i) }}
25+
{{- end }}
26+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- if .Values.pgBackRest.s3.createS3Secret }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ .Values.pgBackRest.s3.s3Secret }}
6+
type: Opaque
7+
data:
8+
s3.conf: {{ include "postgres.s3.full" . | b64enc }}
9+
{{- end }}

0 commit comments

Comments
 (0)