Skip to content

Commit 9891e10

Browse files
committed
chore(postgresql-cluster):adjust patroni config use configmap
1 parent c317ad3 commit 9891e10

6 files changed

Lines changed: 88 additions & 22 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ Create the name of the service account to use.
4242
{{- end -}}
4343
{{- end -}}
4444

45+
{{/*
46+
Return true if a configmap object should be created for MySQL Secondary
47+
*/}}
48+
{{- define "patroni.createConfigmap" -}}
49+
{{- if and .Values.configuration }}
50+
{{- true -}}
51+
{{- else -}}
52+
{{- end -}}
53+
{{- end -}}
54+
4555
{{/*
4656
Create patroni envs.
4757
*/}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if (include "patroni.createConfigmap" .) }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}-cm
6+
namespace: {{ include "common.names.namespace" . | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
{{- if .Values.commonLabels }}
9+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
10+
{{- end }}
11+
cluster-name: {{ template "patroni.fullname" . }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
data:
16+
patroni.sh: |-
17+
{{- include "common.tplvalues.render" ( dict "value" .Values.configuration "context" $ ) | nindent 4 }}
18+
{{- end -}}
19+

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

Lines changed: 0 additions & 12 deletions
This file was deleted.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
{{- /*
2-
Copyright VMware, Inc.
3-
SPDX-License-Identifier: APACHE-2.0
4-
*/}}
5-
61
{{- if .Values.networkPolicy.enabled }}
72
kind: NetworkPolicy
83
apiVersion: {{ template "common.capabilities.networkPolicy.apiVersion" . }}
@@ -13,6 +8,7 @@ metadata:
138
{{- if .Values.commonLabels }}
149
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
1510
{{- end }}
11+
cluster-name: {{ template "patroni.fullname" . }}
1612
{{- if .Values.commonAnnotations }}
1713
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1814
{{- end }}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ spec:
2626
cluster-name: {{ template "patroni.fullname" . }}
2727
spec:
2828
serviceAccountName: {{ template "patroni.serviceAccountName" . }}
29+
30+
# securityContext:
31+
# runAsUser: postgres
32+
# fsGroup: postgres
2933
containers:
3034
- name: {{ .Chart.Name }}
3135
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
3236
imagePullPolicy: {{ .Values.image.pullPolicy }}
37+
# securityContext:
38+
# runAsUser: postgres
39+
# fsGroup: postgres
3340
env:
3441
{{- include "patroni.envs" . | indent 8 }}
3542
{{- if .Values.env }}
@@ -78,9 +85,9 @@ spec:
7885
volumeMounts:
7986
- name: storage-volume
8087
mountPath: "{{ .Values.persistentVolume.mountPath }}"
81-
# - mountPath: /etc/patroni
82-
# name: patroni-config
83-
# readOnly: true
88+
- mountPath: "/opt/drycc/scripts/patroni/"
89+
name: patroni-config
90+
# readOnly: true
8491
{{- if .Values.walE.enable }}
8592
{{- if .Values.walE.kubernetesSecret }}
8693
- name: {{ .Values.walE.kubernetesSecret }}
@@ -110,8 +117,8 @@ spec:
110117
{{- end }}
111118
volumes:
112119
- name: patroni-config
113-
secret:
114-
secretName: {{ template "patroni.fullname" . }}
120+
configMap:
121+
name: {{ template "common.names.fullname" . }}-cm
115122
{{- if .Values.walE.enable }}
116123
{{- if .Values.walE.kubernetesSecret }}
117124
- name: {{ .Values.walE.kubernetesSecret }}

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,52 @@ kubernetes:
2727
# Extra custom environment variables.
2828
env: {}
2929

30+
#
31+
#custom patroni.yaml used by patroni boot
32+
# configuration: {}
33+
configuration: |
34+
cat > /home/postgres/patroni.yml <<__EOF__
35+
log:
36+
level: DEBUG
37+
bootstrap:
38+
dcs:
39+
postgresql:
40+
use_pg_rewind: true
41+
use_slots: true
42+
pg_hba:
43+
- host all all 0.0.0.0/0 scram-sha-256
44+
- host replication ${PATRONI_REPLICATION_USERNAME} 0.0.0.0/0 scram-sha-256
45+
parameters:
46+
wal_level: hot_standby
47+
hot_standby: "on"
48+
max_connections: 1000
49+
max_worker_processes: 8
50+
wal_keep_segments: 8
51+
max_wal_senders: 10
52+
max_replication_slots: 10
53+
max_prepared_transactions: 0
54+
max_locks_per_transaction: 64
55+
wal_log_hints: "on"
56+
track_commit_timestamp: "off"
57+
archive_mode: "on"
58+
archive_timeout: 1800s
59+
initdb:
60+
- auth-host: scram-sha-256
61+
- auth-local: trust
62+
- encoding: UTF8
63+
- locale: en_US.UTF-8
64+
- data-checksums
65+
restapi:
66+
connect_address: '${PATRONI_KUBERNETES_POD_IP}:8008'
67+
postgresql:
68+
connect_address: '${PATRONI_KUBERNETES_POD_IP}:5432'
69+
authentication:
70+
superuser:
71+
password: '${PATRONI_SUPERUSER_PASSWORD}'
72+
replication:
73+
password: '${PATRONI_REPLICATION_PASSWORD}'
74+
__EOF__
75+
3076
walE:
3177
# Specifies whether Wal-E should be enabled
3278
enable: false

0 commit comments

Comments
 (0)