Skip to content

Commit fbe33a4

Browse files
Jonathan S. Katzjkatz
Jonathan S. Katz
authored andcommitted
Major rewrite of Postgres Helm chart
This makes it possible to customize every attribute of deploying a Postgres cluster. There are some attributes that are simplified for basic installs, while allowing for full flexiblity of the chart. Issue: [sc-12191]
1 parent 94814e4 commit fbe33a4

File tree

3 files changed

+334
-21
lines changed

3 files changed

+334
-21
lines changed

helm/postgres/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: postgrescluster
33
description: A Helm chart for Kubernetes
44
type: application
5-
version: 0.1.1
5+
version: 0.2.0
66
appVersion: 5.0.3

helm/postgres/templates/postgres.yaml

Lines changed: 111 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
apiVersion: postgres-operator.crunchydata.com/v1beta1
22
kind: PostgresCluster
33
metadata:
4-
name: {{ required "You must give your Postgres cluster a name" .Values.name }}
4+
name: {{ default .Release.Name .Values.name }}
55
spec:
6-
image: {{ default "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.4-1" .Values.postgres | quote }}
76
postgresVersion: {{ default 13 .Values.postgresVersion }}
7+
{{- if .Values.postGISVersion }}
8+
postGISVersion: {{ quote .Values.postGISVersion }}
9+
{{- end }}
10+
{{- if .Values.imagePostgres }}
11+
image: {{ .Values.imagePostgres | quote }}
12+
{{- end }}
13+
{{- if .Values.port }}
14+
port: {{ .Values.port }}
15+
{{- end }}
16+
{{- if .Values.instances }}
817
instances:
9-
- name: instance1
18+
{{ toYaml .Values.instances | indent 4 }}
19+
{{- else }}
20+
instances:
21+
- name: {{ default "instance1" .Values.instanceName | quote }}
22+
replicas: {{ default 1 .Values.instanceReplicas }}
1023
dataVolumeClaimSpec:
1124
accessModes:
1225
- "ReadWriteOnce"
1326
resources:
1427
requests:
15-
storage: 1Gi
28+
storage: {{ default "1Gi" .Values.instanceSize | quote }}
29+
{{- if or .Values.instanceMemory .Values.instanceCPU }}
30+
resources:
31+
limits:
32+
cpu: {{ default "" .Values.instanceCPU | quote }}
33+
memory: {{ default "" .Values.instanceMemory | quote }}
34+
{{- end }}
35+
{{- end }}
1636
backups:
1737
pgbackrest:
18-
image: {{ default "registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.35-0" .Values.pgBackRest | quote }}
38+
{{- if .Values.imagePgBackRest }}
39+
image: {{ .Values.imagePgBackRest | quote }}
40+
{{- end }}
41+
{{- if .Values.pgBackRestConfig }}
42+
{{ toYaml .Values.pgBackRestConfig | indent 6 }}
43+
{{- else }}
1944
repos:
2045
- name: repo1
2146
volume:
@@ -24,7 +49,86 @@ spec:
2449
- "ReadWriteOnce"
2550
resources:
2651
requests:
27-
storage: 1Gi
52+
storage: {{ default "1Gi" .Values.backupsSize | quote }}
53+
{{- end }}
54+
{{- if or .Values.pgBouncerReplicas .Values.pgBouncerConfig }}
2855
proxy:
2956
pgBouncer:
30-
image: {{ default "registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-3" .Values.pgBouncer | quote}}
57+
{{- if .Values.imagePgBouncer }}
58+
image: {{ .Values.imagePgBouncer | quote }}
59+
{{- end }}
60+
{{- if .Values.pgBouncerConfig }}
61+
{{ toYaml .Values.pgBouncerConfig | indent 6 }}
62+
{{- else }}
63+
replicas: {{ .Values.pgBouncerReplicas }}
64+
{{- end }}
65+
{{- end }}
66+
{{- if .Values.patroni }}
67+
patroni:
68+
{{ toYaml .Values.patroni | indent 4 }}
69+
{{- end }}
70+
{{- if .Values.users }}
71+
users:
72+
{{ toYaml .Values.users | indent 4 }}
73+
{{- end }}
74+
{{- if .Values.service }}
75+
service:
76+
{{ toYaml .Values.service | indent 4 }}
77+
{{- end }}
78+
{{- if .Values.dataSource }}
79+
service:
80+
{{ toYaml .Values.dataSource | indent 4 }}
81+
{{- end }}
82+
{{- if .Values.databaseInitSQL }}
83+
databaseInitSQL:
84+
name: {{ required "A ConfigMap name is required for running bootstrap SQL." .Values.databaseInitSQL.name | quote }}
85+
key: {{ required "A key in a ConfigMap containing any bootstrap SQL is required." .Values.databaseInitSQL.key | quote }}
86+
{{- end }}
87+
{{- if .Values.imagePullPolicy }}
88+
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
89+
{{- end }}
90+
{{- if .Values.imagePullSecrets }}
91+
imagePullSecrets:
92+
{{ toYaml .Values.imagePullSecrets | indent 4 }}
93+
{{- end }}
94+
{{- if .Values.disableDefaultPodScheduling }}
95+
disableDefaultPodScheduling: true
96+
{{- end }}
97+
{{- if .Values.metadata }}
98+
metadata:
99+
{{ toYaml .Values.metadata | indent 4 }}
100+
{{- end }}
101+
{{- if .Values.monitoring }}
102+
monitoring:
103+
pgmonitor:
104+
exporter:
105+
image: {{ default "" .Values.imageExporter | quote }}
106+
{{- if .Values.monitoringConfig }}
107+
{{ toYaml .Values.monitoringConfig | indent 8 }}
108+
{{- end }}
109+
{{- end }}
110+
{{- if .Values.shutdown }}
111+
shutdown: true
112+
{{- end }}
113+
{{- if .Values.standby }}
114+
standby:
115+
enabled: {{ .Values.standby.enabled }}
116+
repoName: {{ required "repoName must be set when enabling standby mode." .Values.standby.repoName }}
117+
{{- end }}
118+
{{- if .Values.supplementalGroups }}
119+
supplementalGroups:
120+
{{ toYaml .Values.supplementalGroups | indent 4 }}
121+
{{- end }}
122+
{{- if .Values.openshift }}
123+
openshift: true
124+
{{- else if eq .Values.openshift false }}
125+
openshift: false
126+
{{- end }}
127+
{{- if .Values.customTLSSecret }}
128+
customTLSSecret:
129+
{{ toYaml .Values.customTLSSecret | indent 4 }}
130+
{{- end }}
131+
{{- if .Values.customReplicationTLSSecret }}
132+
customReplicationTLSSecret:
133+
{{ toYaml .Values.customReplicationTLSSecret | indent 4 }}
134+
{{- end }}

helm/postgres/values.yaml

Lines changed: 222 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,228 @@
11
---
2-
# Cluster name
3-
name: hippo
2+
# For a full explanation of how to set up the custom resource, please refer to
3+
# the documentation:
4+
# https://access.crunchydata.com/documentation/postgres-operator/v5/
45

5-
# postgresVersion should match the version of Potsgres you are deploying from
6-
# the image. This defaults to the below value.
6+
###########
7+
# General #
8+
###########
9+
10+
# name is the name of the cluster. This defaults to the name of the Helm
11+
# release.
12+
# name: hippo
13+
14+
# postgresVersion sets the version to deploy. This version number needs to be
15+
# available as one of the "RELATED_IMAGE_POSTGRES_..." images as part of the PGO
16+
# installation if you want to deploy the image without setting the "postgres"
17+
# image variable. This defaults to the below value.
718
# postgresVersion: 13
819

9-
# postgres can be a Postgres or GIS-enabled Postgres image. This defaults to the
10-
# below value
11-
# postgres: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.4-1
20+
# postGISVersion if sets and coupled with a PostGIS enabled container, enables
21+
# PostGIS. This version number needs to be available as one of the
22+
# "RELATED_IMAGE_POSTGRES_..." images as part of the PGO installation if you
23+
# want to deploy the image without setting the "postgres" image variable.
24+
# postGISVersion: 3.1
25+
26+
# NOTE: pgBackRest is enabled by default. It must be set in
27+
# "RELATED_IMAGE_PGBACKREST" on the PGO deployment, otherwise you will need to
28+
# override the "pgBackRest" image.
29+
30+
# pgBouncerReplicas sets the number of pgBouncer instances to deploy. The
31+
# default is 0. You need to set this to at least 1 to deploy pgBouncer or set
32+
# "pgBouncerConfig". Setting "pgBouncerConfig" will override the value of
33+
# pgBouncerReplicas. The "RELATED_IMAGE_PGBOUNCER" in the PGO deployment must be
34+
# set if you want to enable this without explicitly setting "pgBouncer".
35+
# pgBouncerReplicas: 1
36+
37+
# monitoring enables the ability to monitor the Postgres cluster through a
38+
# metrics exporter than can be scraped by Prometheus. This defaults to the value
39+
# below.
40+
# monitoring: false
41+
42+
###################
43+
# Image Overrides #
44+
###################
45+
46+
# imagePostgres can be a Postgres or GIS-enabled Postgres image. This defaults to the
47+
# below value. "postgresVersion" needs to match the version of Postgres that is
48+
# used here. If using the GIS-enabled Postgres image, you need to ensure
49+
# "postGISVersion" matches the version of PostGIS used.
50+
# imagePostgres: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.4-1
51+
52+
# imagePgBackRest is the pgBackRest backup utility image. This defaults to the
53+
# below value.
54+
# imagePgBackRest: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.35-0
55+
56+
# imagePgBouncer is the image for the PgBouncer connection pooler. This defaults
57+
# to the below value.
58+
# imagePgBouncer: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-3
59+
60+
# imageExporter is the image name for the exporter used as a part of monitoring.
61+
# This defaults to the value below.
62+
# imageExporter: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi8-5.0.3-0
63+
64+
###########################
65+
# Basic Postgres Settings #
66+
###########################
67+
68+
# instanceName lets you set the name of your instances. This defaults to
69+
# the value below. Setting "instances" overrides this value.
70+
# instanceName: instance1
71+
72+
# instanceSize sets the size of the volume that contains the data. This defaults
73+
# to the value below. Settings "instances" overrides this value.
74+
# instanceSize: 1Gi
75+
76+
# instanceMemory sets the memory limit for the Postgres instances. This defaults
77+
# to no limit being set, but an example value is set below. Settings "instances"
78+
# overrides this value.
79+
# instanceMemory: 2Gi
80+
81+
# instanceCPU sets the CPU limit for the Postgres instances. This defaults to
82+
# no limit being set, but an example value is set below. Setting "instances"
83+
# overrides this value.
84+
# instanceCPU: 1000m
85+
86+
# instanceReplicas lets you set the total number of Postgres replicas. This
87+
# defaults to the value below. More than on replica enables high availability
88+
# (HA). Settings "instances" overrides this value.
89+
# instanceReplicas: 1
90+
91+
##############################
92+
# Advanced Postgres Settings #
93+
##############################
94+
95+
# instances allows you to define one or more Postgres instance sets. By default,
96+
# PGO will only deploy a single instance. Each instance set has similar
97+
# characteristics to the other instances in the set, e.g. storage size, resource
98+
# etc. You can have multiple replicas within an instance set.
99+
#
100+
# This allows you to fully customize the topology of your Postgres instances.
101+
#
102+
# For example, to set up an instance set with HA (due to the default pod
103+
# topology spread constraints)
104+
#
105+
# instances:
106+
# - name: pgha1
107+
# replicas: 2
108+
# dataVolumeClaimSpec:
109+
# accessModes:
110+
# - "ReadWriteOnce"
111+
# resources:
112+
# requests:
113+
# storage: 1Gi
114+
# instances: {}
115+
116+
# port sets the port that Postgres listens on. Defaults to 5432.
117+
# port: 5432
118+
119+
# patroni lets you set the Patroni configuration for the Postgres cluster.
120+
# for example, to set up synchronous replication:
121+
# patroni:
122+
# dynamicConfiguration:
123+
# synchronous_mode: true
124+
# postgresql:
125+
# parameters:
126+
# synchronous_commit: "on"
127+
# patroni: {}
128+
129+
# users sets any custom Postgres users and databases that they have access to
130+
# as well as any permossions assoicated with the user account.
131+
# users: {}
132+
133+
# dataSource specifies a data source for bootstrapping a Postgres cluster.
134+
# dataSource: {}
135+
136+
# customTLSSecret references a Secret that contains the relevant information for
137+
# bringing external TLS artifacts to a PostgreSQL cluster. This provides the
138+
# TLS for the cluster itself.
139+
# customTLSSecret: {}
140+
141+
# customReplicationTLSSecret references a Secret that contains the relevant
142+
# information for bringing external TLS artifacts to a PostgreSQL cluster. This
143+
# provides the information for the replication user.
144+
# customReplicationTLSSecret: {}
145+
146+
# databaseInitSQL referencs a ConfigMap that contains a SQL file that should be
147+
# run a cluster bootstrap.
148+
# databaseInitSQL:
149+
# name: bootstrap-sql
150+
# key: bootstrap.sql
151+
152+
# standby sets whether or not to run this as a standby cluster. Both of the
153+
# values below are required to enable a standby cluster. Setting "enabled" to
154+
# "true" eunables the standby cluster while "repoName" points to a pgBackRest
155+
# archive to replay WAL files from.
156+
# standby:
157+
# enabled: false
158+
# repoName: repo1
159+
160+
# shutdown when set scales the entire workload to zero. By default this is not
161+
# set.
162+
# shutdown: true
163+
164+
#################################
165+
# Backups / pgBackRest Settings #
166+
#################################
167+
168+
# backupsSize sets the storage size of the backups to a PVC. This can be
169+
# overridden by "pgBackRestConfig", if set. Defaults to the value velow.
170+
# backupsSize: 1Gi
171+
172+
# pgBackRestConfig allows for the configuration of every pgBackRest option
173+
# except for "image", which is set by "pgBackRest".
174+
# pgBackRestConfig: {}
175+
176+
################################
177+
# Pooling / pgBouncer Settings #
178+
################################
179+
180+
# pgBouncerConfig sets all of the pgBouncer portion of the spec except for
181+
# image. To set image, you need to set the "pgBouncer" setting.
182+
# pgBouncerConfig: {}
183+
184+
#######################
185+
# Monitoring Settings #
186+
#######################
187+
188+
# monitoringConfig sets all of the monitoring portion of the spec except for the
189+
# image. To set the image, which also enables monitoring, you need to set the
190+
# "monitoring" setting.
191+
# monitoringConfig: {}
192+
193+
#######################
194+
# Kubernetes Settings #
195+
#######################
196+
197+
# metadata contains any metadata that should be applied to all PGO managed
198+
# objects in this Postgres cluster. This includes "annotations" and "labels" as
199+
# subkeys.
200+
# metadata: {}
201+
202+
# service customizes the Service that exposes the Postgres primary.
203+
# service: {}
204+
205+
# imagePullPolicy sets the pull policy for all the images. This defaults to
206+
# the Kubernetes heuristic:
207+
# https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting
208+
# imagePullPolicy: IfNotPresent
209+
210+
# imagePullSecrets references Secrets that credentials for pulling image from
211+
# private repositories
212+
# imagePullSecrets: []
213+
214+
# supplementalGroups sets any group IDs that should be assigned to
215+
# Pods, particularly around file system contraints within a system
216+
# supplementalGroups: []
12217

13-
# pgBackRest is the pgBackRest backup utility image. This defaults to the below
14-
# value
15-
# pgBackRest: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.35-0
218+
# disableDefaultPodScheduling if set to true, will disable any of the default
219+
# scheduling constraints for Pods, such as the default Pod Topology Spread
220+
# Constraints. If set to false or unset, the default scheduling constraints will
221+
# be used in addition to any customizations that are added in.
222+
# disableDefaultPodScheduling: false
16223

17-
# pgBouncer is the image for the PgBouncer connection pooler. This defaults to
18-
# the below value
19-
# pgBouncer: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-3
224+
# openshift can set explicitly if this is an OpenShift cluster, or a cluster
225+
# that uses a SecurityContextConstraint. This usually does not need to be set,
226+
# but you may want to explicitly set it to "false" when using a SCC like
227+
# "anyuid"
228+
# openshift: false

0 commit comments

Comments
 (0)