Skip to content

Commit b940caa

Browse files
committed
chore(postgresql-cluster): add plans
1 parent 5c95bf4 commit b940caa

29 files changed

Lines changed: 837 additions & 173 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if (include "patroni.createConfigmap" .) }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}-postgresql
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+
custom_conf.conf: |-
17+
{{- include "common.tplvalues.render" ( dict "value" .Values.postgresql.config "context" $ ) | nindent 4 }}
18+
{{- end -}}

addons/postgresql-cluster/15/chart/postgresql-cluster/templates/configmap.yaml renamed to addons/postgresql-cluster/15/chart/postgresql-cluster/templates/cm-patroni.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:
5-
name: {{ template "common.names.fullname" . }}-cm
5+
name: {{ template "common.names.fullname" . }}-patroni
66
namespace: {{ include "common.names.namespace" . | quote }}
77
labels: {{- include "common.labels.standard" . | nindent 4 }}
88
{{- if .Values.commonLabels }}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ spec:
107107
mountPath: "{{ .Values.persistentVolume.mountPath }}"
108108
- mountPath: "/opt/drycc/postgresql/scripts/"
109109
name: patroni-config
110+
- mountPath: "/opt/drycc/postgresql/config/"
111+
name: postgresql-config
110112
# readOnly: true
111113
resources:
112114
{{ toYaml .Values.resources | indent 10 }}
@@ -216,7 +218,10 @@ spec:
216218
volumes:
217219
- name: patroni-config
218220
configMap:
219-
name: {{ template "common.names.fullname" . }}-cm
221+
name: {{ template "common.names.fullname" . }}-patroni
222+
- name: postgresql-config
223+
configMap:
224+
name: {{ template "common.names.fullname" . }}-postgresql
220225
{{- if not .Values.persistentVolume.enabled }}
221226
- name: storage-volume
222227
emptyDir: {}

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,23 @@ env: {}
4141
#custom patroni.yaml used by patroni boot
4242
# configuration: {}
4343
preInitScript: |
44-
mkdir /home/postgres/pgdata/log
44+
mkdir -p /home/postgres/pgdata/log
4545
ln -sf /dev/stdout "/home/postgres/pgdata/log/postgresql.csv"
4646
cat > /opt/drycc/postgresql/patroni.yml <<__EOF__
4747
log:
4848
level: INFO
49+
restapi:
50+
listen: 0.0.0.0:8008
51+
connect_address: 0.0.0.0:8008
52+
authentication:
53+
username: NzUwNjg3MTEtMDgzOS00YTNkLWEyNjAt
54+
password: YjJjMDNjYjQtMDA0Ny00NTgwLTgwYjMt
4955
bootstrap:
5056
dcs:
57+
ttl: 30
58+
loop_wait: 10
59+
retry_timeout: 10
60+
maximum_lag_on_failover: 1048576
5161
postgresql:
5262
use_pg_rewind: true
5363
use_slots: true
@@ -57,12 +67,13 @@ preInitScript: |
5767
- host all all 0.0.0.0/0 scram-sha-256
5868
- host replication ${PATRONI_REPLICATION_USERNAME} 0.0.0.0/0 scram-sha-256
5969
- host replication postgres 0.0.0.0/0 scram-sha-256
70+
custom_conf: '/opt/drycc/postgresql/config/custom_conf.conf'
6071
parameters:
6172
wal_level: hot_standby
6273
hot_standby: "on"
6374
max_connections: 1005
6475
max_worker_processes: 8
65-
wal_keep_segments: 8
76+
wal_keep_segments: 1024
6677
max_wal_senders: 10
6778
max_replication_slots: 10
6879
max_prepared_transactions: 0
@@ -71,7 +82,7 @@ preInitScript: |
7182
track_commit_timestamp: "off"
7283
archive_mode: "on"
7384
archive_timeout: 300s
74-
archive_command: sh /opt/drycc/postgresql/walbackup.sh %f
85+
archive_command: sh /opt/drycc/postgresql/walbackup.sh %p
7586
# timescaledb.license: 'timescale'
7687
shared_preload_libraries: 'auto_explain,pg_stat_statements'
7788
log_destination: 'csvlog'
@@ -124,6 +135,17 @@ postInitScript: |
124135
echo "Skipping user creation"
125136
echo "Skipping database creation"
126137
fi
138+
postgresql:
139+
config: |-
140+
log_min_duration_statement = 1008
141+
max_wal_size = 4GB
142+
min_wal_size = 4GB
143+
max_connections = 1005
144+
max_worker_processes = 8
145+
max_wal_senders = 10
146+
max_replication_slots = 10
147+
max_prepared_transactions = 0
148+
max_locks_per_transaction = 64
127149
128150
patroni:
129151
## @param patroni.podAnnotations Additional pod annotations for Postgresql patroni pods
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
credential:
2-
{{- if (eq .Values.service.type "LoadBalancer") }}
2+
{{- if (eq .Values.service.type "LoadBalancer") }}
33
- name: host
44
valueFrom:
5-
secretKeyRef:
6-
name: {{ template "common.names.fullname" . }}-svcbind-custom-user
7-
jsonpath: '{ .data.host }'
5+
serviceRef:
6+
name: {{ template "common.names.fullname" . }}-master
7+
jsonpath: '{.spec.clusterIPs[*]}'
8+
- name: hostrepl
9+
valueFrom:
10+
serviceRef:
11+
name: {{ template "common.names.fullname" . }}-repl
12+
jsonpath: '{.spec.clusterIPs[*]}'
813
- name: database
914
valueFrom:
1015
secretKeyRef:
11-
name: {{ template "common.names.fullname" . }}-svcbind-custom-user
12-
jsonpath: '{ .data.database }'
16+
name: {{ template "common.names.fullname" . }}
17+
jsonpath: '{ .data.data-name }'
1318
- name: password
1419
valueFrom:
1520
secretKeyRef:
16-
name: {{ template "common.names.fullname" . }}-svcbind-custom-user
17-
jsonpath: '{ .data.password }'
21+
name: {{ template "common.names.fullname" . }}
22+
jsonpath: '{ .data.data-password }'
1823
- name: username
1924
valueFrom:
2025
secretKeyRef:
21-
name: {{ template "common.names.fullname" . }}-svcbind-custom-user
22-
jsonpath: '{ .data.username }'
23-
- name: portro
24-
valueFrom:
25-
secretKeyRef:
26-
name: {{ template "common.names.fullname" . }}-svcbind-custom-user
27-
jsonpath: '{ .data.portro }'
28-
- name: portrw
29-
valueFrom:
30-
secretKeyRef:
31-
name: {{ template "common.names.fullname" . }}-svcbind-custom-user
32-
jsonpath: '{ .data.portrw }'
33-
{{- end }}
26+
name: {{ template "common.names.fullname" . }}
27+
jsonpath: '{ .data.data-user }'
28+
- name: port
29+
value: 5432
30+
{{- end }}
3431

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

Lines changed: 58 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,75 @@
22
##
33
fullnameOverride: hb-postgresql-cluster-standard-10
44

5-
preInitScript: |
6-
cat > /opt/drycc/postgresql/patroni.yml <<__EOF__
7-
log:
8-
level: DEBUG
9-
bootstrap:
10-
dcs:
11-
postgresql:
12-
use_pg_rewind: true
13-
use_slots: true
14-
pg_hba:
15-
- local all all peer
16-
- host all tea_mon 127.0.0.1/32 trust
17-
- host all all 0.0.0.0/0 scram-sha-256
18-
- host replication ${PATRONI_REPLICATION_USERNAME} 0.0.0.0/0 scram-sha-256
19-
parameters:
20-
wal_level: hot_standby
21-
hot_standby: "on"
22-
max_connections: 1005
23-
max_worker_processes: 8
24-
wal_keep_segments: 8
25-
max_wal_senders: 10
26-
max_replication_slots: 10
27-
max_prepared_transactions: 0
28-
max_locks_per_transaction: 64
29-
wal_log_hints: "on"
30-
track_commit_timestamp: "off"
31-
archive_mode: "on"
32-
archive_timeout: 1800s
33-
archive_command: /bin/true
34-
# timescaledb.license: 'timescale'
35-
shared_preload_libraries: 'pg_stat_statements'
36-
initdb:
37-
- auth-host: scram-sha-256
38-
- auth-local: trust
39-
- encoding: UTF8
40-
- locale: en_US.UTF-8
41-
- data-checksums
42-
post_bootstrap: sh /opt/drycc/postgresql/scripts/post_init.sh
43-
restapi:
44-
connect_address: '${PATRONI_KUBERNETES_POD_IP}:8008'
45-
postgresql:
46-
connect_address: '${PATRONI_KUBERNETES_POD_IP}:5432'
47-
authentication:
48-
superuser:
49-
username: postgres
50-
password: '${PATRONI_SUPERUSER_PASSWORD}'
51-
replication:
52-
username: standby
53-
password: '${PATRONI_REPLICATION_PASSWORD}'
54-
rewind: # Has no effect on postgres 10 and lower
55-
username: rewinder
56-
password: '${PATRONI_REWIND_USERNAME}'
57-
watchdog:
58-
mode: off
59-
__EOF__
5+
postgresql:
6+
config: |-
7+
# Connectivity
8+
max_connections = 980
9+
superuser_reserved_connections = 3
10+
11+
# Memory Settings
12+
shared_buffers = '256 MB'
13+
work_mem = '32 MB'
14+
maintenance_work_mem = '320 MB'
15+
huge_pages = off
16+
effective_cache_size = '1 GB'
17+
effective_io_concurrency = 100 # concurrent IO only really activated if OS supports posix_fadvise function
18+
random_page_cost = 1.25 # speed of random disk access relative to sequential access (1.0)
19+
20+
# Monitoring
21+
track_io_timing=on # measure exact block IO times
22+
track_functions=pl # track execution times of pl-language procedures if any
23+
24+
# Replication
25+
max_wal_senders = 10
26+
synchronous_commit = on
27+
28+
# Checkpointing:
29+
checkpoint_timeout = '15 min'
30+
checkpoint_completion_target = 0.9
31+
max_wal_size = '1024 MB'
32+
min_wal_size = '512 MB'
33+
34+
# WAL writing
35+
wal_compression = on
36+
wal_buffers = -1 # auto-tuned by Postgres till maximum of segment size (16MB by default)
37+
wal_writer_delay = 200ms
38+
wal_writer_flush_after = 1MB
39+
wal_keep_size = '3650 MB'
40+
41+
# Background writer
42+
bgwriter_delay = 200ms
43+
bgwriter_lru_maxpages = 100
44+
bgwriter_lru_multiplier = 2.0
45+
bgwriter_flush_after = 0
46+
47+
# Parallel queries:
48+
max_worker_processes = 2
49+
max_parallel_workers_per_gather = 1
50+
max_parallel_maintenance_workers = 1
51+
max_parallel_workers = 2
52+
parallel_leader_participation = on
53+
54+
# Advanced features
55+
enable_partitionwise_join = on
56+
enable_partitionwise_aggregate = on
57+
jit = on
58+
max_slot_wal_keep_size = '1000 MB'
59+
track_wal_io_timing = on
60+
maintenance_io_concurrency = 100
6061
6162
resources:
6263
# If you do want to specify resources, uncomment the following
6364
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
6465
limits:
6566
cpu: 1000m
66-
memory: 1Gi
67+
memory: 2Gi
6768
# hugepages-2Mi: 4Mi
6869
requests:
6970
cpu: 1000m
70-
memory: 1Gi
71+
memory: 2Gi
7172

7273
persistentVolume:
7374
enabled: true
7475
size: 10G
7576

76-
metrics:
77-
resources:
78-
limits:
79-
cpu: 1000m
80-
memory: 1Gi
81-
requests:
82-
cpu: 1000m
83-
memory: 1Gi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
credential:
2+
{{- if (eq .Values.service.type "LoadBalancer") }}
3+
- name: host
4+
valueFrom:
5+
serviceRef:
6+
name: {{ template "common.names.fullname" . }}-master
7+
jsonpath: '{.spec.clusterIPs[*]}'
8+
- name: hostrepl
9+
valueFrom:
10+
serviceRef:
11+
name: {{ template "common.names.fullname" . }}-repl
12+
jsonpath: '{.spec.clusterIPs[*]}'
13+
- name: database
14+
valueFrom:
15+
secretKeyRef:
16+
name: {{ template "common.names.fullname" . }}
17+
jsonpath: '{ .data.data-name }'
18+
- name: password
19+
valueFrom:
20+
secretKeyRef:
21+
name: {{ template "common.names.fullname" . }}
22+
jsonpath: '{ .data.data-password }'
23+
- name: username
24+
valueFrom:
25+
secretKeyRef:
26+
name: {{ template "common.names.fullname" . }}
27+
jsonpath: '{ .data.data-user }'
28+
- name: port
29+
value: 5432
30+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"properties": {
5+
"imagePullPolicy": {
6+
"type": "string",
7+
"enum": ["Always", "IfNotPresent", "Never"],
8+
"default": "IfNotPresent",
9+
"title": "Image pull policy"
10+
}
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: "standard-100"
2+
id: c44160a6-5ec4-49e5-af1e-a1c1676871cf
3+
description: "Mysql Cluster standard-100 plan: Disk 100Gi ,vCPUs 4 , RAM 16G , DB MAX Connection 2000"
4+
displayName: "standard-100"
5+
bindable: true
6+
maximum_polling_duration: 1800

0 commit comments

Comments
 (0)