Skip to content

Commit 4efae11

Browse files
committed
chore(postgresql-cluster): allow dyrcc params
1 parent 735f537 commit 4efae11

13 files changed

Lines changed: 61 additions & 194 deletions

File tree

Lines changed: 15 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,17 @@
1-
# ⚠️ Repo Archive Notice
21

3-
As of Nov 13, 2020, charts in this repo will no longer be updated.
4-
For more information, see the Helm Charts [Deprecation and Archive Notice](https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice), and [Update](https://helm.sh/blog/charts-repo-deprecation/).
5-
6-
# Patroni Helm Chart
7-
8-
This directory contains a Kubernetes chart to deploy a five node [Patroni](https://github.com/zalando/patroni/) cluster using a [Spilo](https://github.com/zalando/spilo) and a StatefulSet.
9-
10-
11-
## Prerequisites Details
12-
* Kubernetes 1.9+
13-
* PV support on the underlying infrastructure
14-
15-
## StatefulSet Details
16-
* https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
17-
18-
## StatefulSet Caveats
19-
* https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#limitations
20-
21-
22-
## Chart Details
23-
This chart will do the following:
24-
25-
* Implement a HA scalable PostgreSQL 10 cluster using a Kubernetes StatefulSet.
26-
27-
## Installing the Chart
28-
29-
To install the chart with the release name `my-release`:
30-
31-
```console
32-
$ helm repo add
33-
$ helm dependency update
34-
$ helm install --name my-release postgresql-cluster
35-
```
36-
37-
To install the chart with randomly generated passwords:
38-
39-
```console
40-
$ helm install --name my-release postgresql-cluster \
41-
--set credentials.superuser="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)",credentials.admin="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)",credentials.standby="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)"
42-
```
43-
44-
## Connecting to PostgreSQL
45-
46-
Your access point is a cluster IP. In order to access it spin up another pod:
47-
48-
```console
49-
$ kubectl run -i --tty --rm psql --image=postgres --restart=Never -- bash -il
50-
```
51-
52-
Then, from inside the pod, connect to PostgreSQL:
53-
54-
```console
55-
$ psql -U admin -h my-release-patroni.default.svc.cluster.local postgres
56-
<admin password from values.yaml>
57-
postgres=>
58-
```
59-
60-
## Configuration
61-
62-
The following table lists the configurable parameters of the patroni chart and their default values.
63-
64-
| Parameter | Description | Default |
65-
|-----------------------------------|---------------------------------------------|-----------------------------------------------------|
66-
| `nameOverride` | Override the name of the chart | `nil` |
67-
| `fullnameOverride` | Override the fullname of the chart | `nil` |
68-
| `replicaCount` | Amount of pods to spawn | `5` |
69-
| `image.repository` | The image to pull | `registry.opensource.zalan.do/acid/spilo-10` |
70-
| `image.tag` | The version of the image to pull | `1.5-p5` |
71-
| `image.pullPolicy` | The pull policy | `IfNotPresent` |
72-
| `credentials.superuser` | Password of the superuser | `tea` |
73-
| `credentials.admin` | Password of the admin | `cola` |
74-
| `credentials.standby` | Password of the replication user | `pinacolada` |
75-
| `kubernetes.dcs.enable` | Using Kubernetes as DCS | `true` |
76-
| `kubernetes.configmaps.enable` | Using Kubernetes configmaps instead of endpoints | `false` |
77-
| `etcd.enable` | Using etcd as DCS | `false` |
78-
| `etcd.deployChart` | Deploy etcd chart | `false` |
79-
| `etcd.host` | Host name of etcd cluster | `nil` |
80-
| `etcd.discovery` | Domain name of etcd cluster | `nil` |
81-
| `zookeeper.enable` | Using ZooKeeper as DCS | `false` |
82-
| `zookeeper.deployChart` | Deploy ZooKeeper chart | `false` |
83-
| `zookeeper.hosts` | List of ZooKeeper cluster members | `host1:port1,host2:port,etc...` |
84-
| `consul.enable` | Using Consul as DCS | `false` |
85-
| `consul.deployChart` | Deploy Consul chart | `false` |
86-
| `consul.host` | Host name of consul cluster | `nil` |
87-
| `env` | Extra custom environment variables | `{}` |
88-
| `walE.enable` | Use of Wal-E tool for base backup/restore | `false` |
89-
| `walE.scheduleCronJob` | Schedule of Wal-E backups | `00 01 * * *` |
90-
| `walE.retainBackups` | Number of base backups to retain | `2` |
91-
| `walE.s3Bucket:` | Amazon S3 bucket used for wal-e backups | `nil` |
92-
| `walE.gcsBucket` | GCS storage used for Wal-E backups | `nil` |
93-
| `walE.kubernetesSecret` | K8s secret name for provider bucket | `nil` |
94-
| `walE.backupThresholdMegabytes` | Maximum size of the WAL segments accumulated after the base backup to consider WAL-E restore instead of pg_basebackup | `1024` |
95-
| `walE.backupThresholdPercentage` | Maximum ratio (in percents) of the accumulated WAL files to the base backup to consider WAL-E restore instead of pg_basebackup | `30` |
96-
| `resources` | Any resources you wish to assign to the pod | `{}` |
97-
| `nodeSelector` | Node label to use for scheduling | `{}` |
98-
| `tolerations` | List of node taints to tolerate | `[]` |
99-
| `affinityTemplate` | A template string to use to generate the affinity settings | Anti-affinity preferred on hostname |
100-
| `affinity` | Affinity settings. Overrides `affinityTemplate` if set. | `{}` |
101-
| `schedulerName` | Alternate scheduler name | `nil` |
102-
| `persistentVolume.accessModes` | Persistent Volume access modes | `[ReadWriteOnce]` |
103-
| `persistentVolume.annotations` | Annotations for Persistent Volume Claim` | `{}` |
104-
| `persistentVolume.mountPath` | Persistent Volume mount root path | `/home/postgres/pgdata` |
105-
| `persistentVolume.size` | Persistent Volume size | `2Gi` |
106-
| `persistentVolume.storageClass` | Persistent Volume Storage Class | `volume.alpha.kubernetes.io/storage-class: default` |
107-
| `persistentVolume.subPath` | Subdirectory of Persistent Volume to mount | `""` |
108-
| `rbac.create` | Create required role and rolebindings | `true` |
109-
| `serviceAccount.create` | If true, create a new service account | `true` |
110-
| `serviceAccount.name` | Service account to be used. If not set and `serviceAccount.create` is `true`, a name is generated using the fullname template | `nil` |
111-
112-
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
113-
114-
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
115-
116-
```console
117-
$ helm install --name my-release -f values.yaml incubator/patroni
118-
```
119-
120-
> **Tip**: You can use the default [values.yaml](values.yaml)
121-
122-
## Cleanup
123-
124-
To remove the spawned pods you can run a simple `helm delete <release-name>`.
125-
126-
Helm will however preserve created persistent volume claims,
127-
to also remove them execute the commands below.
128-
129-
```console
130-
$ release=<release-name>
131-
$ helm delete $release
132-
$ kubectl delete pvc -l release=$release
133-
```
134-
135-
## Internals
136-
137-
Patroni is responsible for electing a PostgreSQL master pod by leveraging the
138-
DCS of your choice. After election it adds a `spilo-role=master` label to the
139-
elected master and set the label to `spilo-role=replica` for all replicas.
140-
Simultaneously it will update the `<release-name>-patroni` endpoint to let the
141-
service route traffic to the elected master.
142-
143-
```console
144-
$ kubectl get pods -l spilo-role -L spilo-role
145-
NAME READY STATUS RESTARTS AGE SPILO-ROLE
146-
my-release-patroni-0 1/1 Running 0 9m replica
147-
my-release-patroni-1 1/1 Running 0 9m master
148-
my-release-patroni-2 1/1 Running 0 8m replica
149-
my-release-patroni-3 1/1 Running 0 8m replica
150-
my-release-patroni-4 1/1 Running 0 8m replica
1512
```
3+
dataname:
4+
dbname: dbn
5+
username: admin
6+
password: R3Dv0NEmwZkhhz
7+
networkPolicy.allowNamespaces:
8+
- mx-test1
9+
service.type: ClusterIP
10+
metrics.enabled: true
11+
backup:
12+
enabled: true
13+
s3:
14+
awsAccessKeyID: DO9l771LqiwZkhhz
15+
awsSecretAccessKey: R3Dv0NEmJBo8JFdn1q8jz49ArWwpDjFn
16+
walGS3Prefix: mx-test
17+
```

addons/postgresql-cluster/15/chart/postgresql-cluster/templates/_helpers.tpl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Create the name of the service account to use.
4646
Return true if a cronjob object should be created for Postgresql HA patroni ## TODO feature
4747
*/}}
4848
{{- define "patroni.createCronJob" -}}
49-
{{- if and .Values.walG.enabled }}
49+
{{- if and .Values.backup.enabled }}
5050
{{- true -}}
5151
{{- else -}}
5252
{{- end -}}
@@ -143,35 +143,35 @@ Create patroni envs.
143143
{{/*
144144
Create walg envs.
145145
*/}}
146-
{{- define "walg.envs" }}
147-
{{- if .Values.walG.enabled }}
146+
{{- define "backup.envs" }}
147+
{{- if .Values.backup.enabled }}
148148
- name: USE_WALG
149-
value: {{ .Values.walG.enabled | quote }}
150-
{{- if .Values.walG.retainBackups }}
149+
value: {{ .Values.backup.enabled | quote }}
150+
{{- if .Values.backup.retainBackups }}
151151
- name: BACKUP_NUM_TO_RETAIN
152-
value: {{ .Values.walG.retainBackups | quote}}
152+
value: {{ .Values.backup.retainBackups | quote}}
153153
{{- end }}
154-
{{- if .Values.walG.backupThresholdMegabytes }}
154+
{{- if .Values.backup.backupThresholdMegabytes }}
155155
- name: WALG_BACKUP_THRESHOLD_MEGABYTES
156-
value: {{ .Values.walG.backupThresholdMegabytes | quote }}
156+
value: {{ .Values.backup.backupThresholdMegabytes | quote }}
157157
{{- end }}
158-
{{- if .Values.walG.backupThresholdPercentage }}
158+
{{- if .Values.backup.backupThresholdPercentage }}
159159
- name: WALE_BACKUP_THRESHOLD_PERCENTAGE
160-
value: {{ .Values.walG.backupThresholdPercentage | quote }}
160+
value: {{ .Values.backup.backupThresholdPercentage | quote }}
161161
{{- end }}
162-
{{- if .Values.walG.s3.used }}
162+
{{- if .Values.backup.s3.used }}
163163
- name: AWS_ACCESS_KEY_ID
164-
value: {{ .Values.walG.s3.awsAccessKeyID | quote }}
164+
value: {{ .Values.backup.s3.awsAccessKeyID | quote }}
165165
- name: AWS_SECRET_ACCESS_KEY
166-
value: {{ .Values.walG.s3.awsSecretAccessKey | quote }}
166+
value: {{ .Values.backup.s3.awsSecretAccessKey | quote }}
167167
- name: WALG_S3_PREFIX
168-
value: {{ .Values.walG.s3.walGS3Prefix | quote }}
168+
value: {{ .Values.backup.s3.walGS3Prefix | quote }}
169169
- name: AWS_ENDPOINT
170-
value: {{ .Values.walG.s3.awsEndpoint | quote }}
170+
value: {{ .Values.backup.s3.awsEndpoint | quote }}
171171
- name: AWS_S3_FORCE_PATH_STYLE
172-
value: {{ .Values.walG.s3.awsS3ForcePathStyle | quote }}
172+
value: {{ .Values.backup.s3.awsS3ForcePathStyle | quote }}
173173
- name: AWS_REGION
174-
value: {{ .Values.walG.s3.awsRegion | quote }}
174+
value: {{ .Values.backup.s3.awsRegion | quote }}
175175
{{- end }}
176176
{{- else }}
177177
- name: USE_WALG

addons/postgresql-cluster/15/chart/postgresql-cluster/templates/cronjob.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ metadata:
1919
{{- end }}
2020

2121
spec:
22-
schedule: "{{ .Values.walG.scheduleCronJob }}"
22+
schedule: "{{ .Values.backup.scheduleCronJob }}"
2323
failedJobsHistoryLimit: 1
2424
successfulJobsHistoryLimit: 1
2525
jobTemplate:

addons/postgresql-cluster/15/chart/postgresql-cluster/templates/networkpolicy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
- port: 5432
2424
{{- if and .Values.metrics.enabled }}
2525
- port: {{ .Values.metrics.containerPort }}
26-
{{ end }} ``
26+
{{ end }}
2727
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
2828
from:
2929
{{- if .Values.networkPolicy.allowCurrentNamespace }}

addons/postgresql-cluster/15/chart/postgresql-cluster/templates/sec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ data:
1414
password-superuser: {{ .Values.credentials.superuser | b64enc }}
1515
password-rewind: {{ .Values.credentials.rewind | b64enc }}
1616
password-replication: {{ .Values.credentials.replication | b64enc }}
17-
data-user: {{ .Values.dataname.username | b64enc }}
18-
data-name: {{ .Values.dataname.dbname | b64enc }}
19-
data-password: {{ .Values.dataname.password | b64enc }}
17+
data-user: {{ .Values.database.username | b64enc }}
18+
data-name: {{ .Values.database.dbname | b64enc }}
19+
data-password: {{ .Values.database.password | b64enc }}

addons/postgresql-cluster/15/chart/postgresql-cluster/templates/statefulset.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ spec:
5656
# fsGroup: postgres
5757
env:
5858
{{- include "patroni.envs" . | indent 8 }}
59-
{{- if .Values.walG.enabled }}
60-
{{- include "walg.envs" . | indent 8 }}
59+
{{- if .Values.backup.enabled }}
60+
{{- include "backup.envs" . | indent 8 }}
6161
{{- end }}
6262
{{- if .Values.env }}
6363
{{- range $key, $val := .Values.env }}
@@ -127,7 +127,7 @@ spec:
127127
{{- end }}
128128
env:
129129
- name: DATA_SOURCE_NAME
130-
value: {{ printf "postgresql://tea_mon:password@127.0.0.1:5432/%s?sslmode=disable" $.Values.dataname.dbname }}
130+
value: {{ printf "postgresql://tea_mon:password@127.0.0.1:5432/%s?sslmode=disable" $.Values.database.dbname }}
131131
ports:
132132
- name: http-metrics
133133
containerPort: {{ .Values.metrics.containerPort }}
@@ -161,7 +161,7 @@ spec:
161161
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
162162
{{- end }}
163163
{{- end }}
164-
{{- if .Values.walG.enabled }}
164+
{{- if .Values.backup.enabled }}
165165
- name: {{ .Chart.Name }}-backup
166166
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
167167
imagePullPolicy: {{ .Values.image.pullPolicy }}
@@ -175,7 +175,7 @@ spec:
175175
- |
176176
python3 /opt/drycc/postgresql/pgbackup.py 0.0.0.0 9000
177177
env:
178-
{{- include "walg.envs" . | indent 8 }}
178+
{{- include "backup.envs" . | indent 8 }}
179179
- name: PGHOST
180180
value: localhost
181181
- name: PGPASSWORD

addons/postgresql-cluster/15/chart/postgresql-cluster/values.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ credentials:
2121
rewind: cola
2222
replication: reppasswd
2323

24-
dataname:
24+
database:
2525
dbname: db1
2626
username: us1
2727
password: 111w
@@ -82,7 +82,7 @@ preInitScript: |
8282
track_commit_timestamp: "off"
8383
archive_mode: "on"
8484
archive_timeout: 300s
85-
{{- if .Values.walG.enabled }}
85+
{{- if .Values.backup.enabled }}
8686
archive_command: sh /opt/drycc/postgresql/walbackup.sh %p
8787
{{- else }}
8888
archive_command: /bin/true
@@ -243,15 +243,15 @@ metrics:
243243
limits:
244244
cpu: 100m
245245
memory: 512Mi
246-
# hugepages-2Mi: 4Mi
246+
hugepages-2Mi: 20Mi
247247
requests:
248248
cpu: 100m
249249
memory: 512Mi
250-
walG:
250+
backup:
251251
# Specifies whether Wal-G should be enabled
252-
enabled: false
252+
enabled: true
253253
# Cron schedule for doing base backups
254-
scheduleCronJob: "*/5 * * * *"
254+
scheduleCronJob: "20 0 * * 0"
255255
# Amount of base backups to retain
256256
retainBackups: 2
257257
# Name of the secret that holds the credentials to the bucket
@@ -271,8 +271,9 @@ walG:
271271
awsS3ForcePathStyle: "true"
272272
awsRegion: dx-1
273273

274+
274275
persistentVolume:
275-
enabled: false
276+
enabled: true
276277
size: 10G
277278
## database data Persistent Volume Storage Class
278279
## If defined, storageClassName: <storageClass>
@@ -338,12 +339,13 @@ serviceAccount:
338339
networkPolicy:
339340
## @param networkPolicy.enabled Enable creation of NetworkPolicy resources
340341
##
341-
enabled: false
342+
enabled: true
342343
## @param networkPolicy.allowExternal The Policy model to apply.
343344
## When set to false, only pods with the correct
344345
## client label will have network access to the port Postgresql is listening
345346
## on. When true, Postgresql will accept connections from any source
346347
## (with the correct destination port).
347348
##
348349
allowCurrentNamespace: true
349-
allowNamespaces: []
350+
allowNamespaces:
351+
- mx-test1

addons/postgresql-cluster/15/meta.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ instances_retrievable: true
1515
bindings_retrievable: true
1616
plan_updateable: false
1717
allow_parameters:
18+
- name: "dataname"
19+
description: "database config for values.yaml"
1820
- name: "networkPolicy.allowNamespaces"
1921
description: "networkPolicy allowNamespaces config for values.yaml"
2022
- name: "service.type"
2123
description: "service type config for values.yaml"
2224
- name: "metrics.enabled"
2325
description: "Whether to enable metrics. default true"
24-
- name: "walG.enabled"
26+
- name: "backup.enabled"
2527
description: "Whether to use S3 for backup your data. default true . ps: Make sure there is a available S3 "
26-
- name: "walG.s3.awsAccessKeyID"
28+
- name: "backup.s3.awsAccessKeyID"
2729
description: "S3 awsAccessKeyID"
28-
- name: "walG.s3.awsSecretAccessKey"
30+
- name: "backup.s3.awsSecretAccessKey"
2931
description: "S3 awsSecretAccessKey"
30-
- name: "walG.s3.walGS3Prefix"
32+
- name: "backup.s3.walGS3Prefix"
3133
description: "S3 walGS3Prefix : etc . s3://bucket001"
3234
archive: false

addons/postgresql-cluster/15/plans/standard-10/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ resources:
6565
limits:
6666
cpu: 1000m
6767
memory: 2Gi
68-
# hugepages-2Mi: 4Mi
68+
hugepages-2Mi: 4Mi
6969
requests:
7070
cpu: 1000m
7171
memory: 2Gi

0 commit comments

Comments
 (0)