Skip to content

Commit 704b686

Browse files
committed
chore(postgresql-cluster): add version 18
1 parent 93e8fd0 commit 704b686

51 files changed

Lines changed: 2452 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

addons/index.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ entries:
4949
description: "PostgreSQL is an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance."
5050
- version: 17
5151
description: "PostgreSQL is an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance."
52+
- version: 18
53+
description: "PostgreSQL is an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance."
5254
seaweedfs:
5355
- version: 3
5456
description: "SeaweedFS is a fast distributed storage system for blobs, objects, files, and data lake, for billions of files."
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
annotations:
2+
category: Database
3+
apiVersion: v2
4+
appVersion: "18"
5+
dependencies:
6+
- name: common
7+
repository: oci://registry.drycc.cc/charts
8+
version: ~1.1.1
9+
description: PostgreSQL (Postgres) is an open source object-relational database known for reliability and data integrity. ACID-compliant, it supports foreign keys, joins, views, triggers and stored procedures.
10+
engine: gotpl
11+
home: https://github.com/drycc/charts/tree/master/drycc/postgresql
12+
icon: https://drycc.com/assets/stacks/postgresql/img/postgresql-stack-220x234.png
13+
keywords:
14+
- postgresql
15+
- postgres
16+
- database
17+
- sql
18+
- replication
19+
- cluster
20+
- patroni
21+
maintainers:
22+
- email: zhang.eamon@hotmail.com
23+
name: zhangeamon
24+
name: postgresql
25+
sources:
26+
- https://github.com/drycc-addons/
27+
- https://www.postgresql.org/
28+
version: "18.6"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Patroni can be accessed via port 5432 on the following DNS name from within your cluster:
2+
{{ template "patroni.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
3+
4+
To get your password for superuser run:
5+
6+
# superuser password
7+
PGPASSWORD_SUPERUSER=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "patroni.fullname" . }} -o jsonpath="{.data.password-superuser}" | base64 --decode)
8+
9+
# admin password
10+
PGPASSWORD_ADMIN=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "patroni.fullname" . }} -o jsonpath="{.data.password-admin}" | base64 --decode)
11+
12+
To connect to your database:
13+
14+
1. Run a postgres pod and connect using the psql cli:
15+
# login as superuser
16+
kubectl run -i --tty --rm psql --image=postgres \
17+
--env "PGPASSWORD=$PGPASSWORD_SUPERUSER" \
18+
--command -- psql -U postgres \
19+
-h {{ template "patroni.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local postgres
20+
21+
# login as admin
22+
kubectl run -i -tty --rm psql --image=postgres \
23+
--env "PGPASSWORD=$PGPASSWORD_ADMIN" \
24+
--command -- psql -U admin \
25+
-h {{ template "patroni.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local postgres
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "patroni.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "patroni.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "patroni.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Create the name of the service account to use.
36+
*/}}
37+
{{- define "patroni.serviceAccountName" -}}
38+
{{- if .Values.serviceAccount.create -}}
39+
{{ default (include "patroni.fullname" .) .Values.serviceAccount.name }}
40+
{{- else -}}
41+
{{ default "default" .Values.serviceAccount.name }}
42+
{{- end -}}
43+
{{- end -}}
44+
45+
{{/*
46+
Return true if a cronjob object should be created for Postgresql HA patroni ## TODO feature
47+
*/}}
48+
{{- define "patroni.createCronJob" -}}
49+
{{- if and .Values.backup.enabled }}
50+
{{- true -}}
51+
{{- else -}}
52+
{{- end -}}
53+
{{- end -}}
54+
55+
{{/*
56+
Return true if a cronjob object should be created for Postgresql HA patroni ## TODO feature
57+
*/}}
58+
{{- define "patroni.createLogicalBackupCronJob" -}}
59+
{{- if and .Values.logicalbackup.enabled }}
60+
{{- true -}}
61+
{{- else -}}
62+
{{- end -}}
63+
{{- end -}}
64+
65+
{{/*
66+
Return true if a configmap object should be created for Postgresql HA patroni
67+
*/}}
68+
{{- define "patroni.createConfigmap" -}}
69+
{{- if and .Values.preInitScript }}
70+
{{- true -}}
71+
{{- else -}}
72+
{{- end -}}
73+
{{- end -}}
74+
75+
{{/*
76+
Create patroni envs.
77+
*/}}
78+
{{- define "patroni.envs" }}
79+
{{- if .Values.kubernetes.configmaps.enable }}
80+
- name: KUBERNETES_USE_CONFIGMAPS
81+
value: "true"
82+
{{- end }}
83+
{{- if .Values.kubernetes.endpoints.enable }}
84+
- name: PATRONI_KUBERNETES_USE_ENDPOINTS
85+
value: 'true'
86+
{{- end }}
87+
- name: PATRONI_KUBERNETES_POD_IP
88+
valueFrom:
89+
fieldRef:
90+
fieldPath: status.podIP
91+
- name: PATRONI_KUBERNETES_NAMESPACE
92+
valueFrom:
93+
fieldRef:
94+
fieldPath: metadata.namespace
95+
- name: PATRONI_KUBERNETES_BYPASS_API_SERVICE
96+
value: 'true'
97+
- name: PATRONI_KUBERNETES_LABELS
98+
value: '{application: {{ template "patroni.fullname" . }},release: {{ .Release.Name }},cluster-name: {{ template "patroni.fullname" . }}}'
99+
- name: PATRONI_SUPERUSER_USERNAME
100+
value: postgres
101+
- name: PATRONI_SUPERUSER_PASSWORD
102+
valueFrom:
103+
secretKeyRef:
104+
name: {{ template "patroni.fullname" . }}
105+
key: password-superuser
106+
- name: PATRONI_REPLICATION_USERNAME
107+
value: standby
108+
- name: PATRONI_REPLICATION_PASSWORD
109+
valueFrom:
110+
secretKeyRef:
111+
name: {{ template "patroni.fullname" . }}
112+
key: password-replication
113+
- name: PATRONI_REWIND_USERNAME
114+
value: rewinder
115+
- name: PATRONI_REWIND_PASSWORD
116+
valueFrom:
117+
secretKeyRef:
118+
name: {{ template "patroni.fullname" . }}
119+
key: password-rewind
120+
- name: ADMIN_USER
121+
valueFrom:
122+
secretKeyRef:
123+
name: {{ template "patroni.fullname" . }}
124+
key: admin-user
125+
- name: ADMIN_PASSWORD
126+
valueFrom:
127+
secretKeyRef:
128+
name: {{ template "patroni.fullname" . }}
129+
key: admin-password
130+
- name: PATRONI_SCOPE
131+
value: {{ template "patroni.fullname" . }}
132+
- name: PATRONI_NAME
133+
valueFrom:
134+
fieldRef:
135+
fieldPath: metadata.name
136+
- name: PATRONI_POSTGRESQL_DATA_DIR
137+
value: "{{ .Values.persistentVolume.mountPath }}/data"
138+
- name: PGDATA
139+
value: "{{ .Values.persistentVolume.mountPath }}/data"
140+
- name: PATRONI_POSTGRESQL_PGPASS
141+
value: /tmp/pgpass
142+
- name: PATRONI_POSTGRESQL_LISTEN
143+
value: '0.0.0.0:5432'
144+
- name: PATRONI_RESTAPI_LISTEN
145+
value: '0.0.0.0:8008'
146+
{{- end -}}
147+
148+
{{/*
149+
Return true if a configmap object should be created for PG backup.
150+
*/}}
151+
{{- define "backup.createConfigmap" -}}
152+
{{- if and .Values.backup.enabled }}
153+
{{- true -}}
154+
{{- else -}}
155+
{{- end -}}
156+
{{- end -}}
157+
158+
{{/*
159+
Generate random password
160+
*/}}
161+
162+
{{/*
163+
Get the super user password ;
164+
*/}}
165+
{{- define "credentials.superuserValue" }}
166+
{{- if .Values.credentials.superuser }}
167+
{{- .Values.credentials.superuser -}}
168+
{{- else -}}
169+
{{- include "getValueFromSecret" (dict "Namespace" .Release.Namespace "Name" (include "common.names.fullname" .) "Length" 10 "Key" "password-superuser") -}}
170+
{{- end -}}
171+
{{- end }}
172+
173+
{{/*
174+
Get the rewind password ;
175+
*/}}
176+
{{- define "credentials.rewindValue" }}
177+
{{- if .Values.credentials.rewind }}
178+
{{- .Values.credentials.rewind -}}
179+
{{- else -}}
180+
{{- include "getValueFromSecret" (dict "Namespace" .Release.Namespace "Name" (include "common.names.fullname" .) "Length" 10 "Key" "password-rewind") -}}
181+
{{- end -}}
182+
{{- end }}
183+
184+
{{/*
185+
Get the replication password ;
186+
*/}}
187+
{{- define "credentials.replicationValue" }}
188+
{{- if .Values.credentials.replication }}
189+
{{- .Values.credentials.replication -}}
190+
{{- else -}}
191+
{{- include "getValueFromSecret" (dict "Namespace" .Release.Namespace "Name" (include "common.names.fullname" .) "Length" 10 "Key" "password-replication") -}}
192+
{{- end -}}
193+
{{- end }}
194+
195+
{{/*
196+
Get the administrator password ;
197+
*/}}
198+
{{- define "adminRole.passwordValue" }}
199+
{{- if .Values.adminRole.password }}
200+
{{- .Values.adminRole.password -}}
201+
{{- else -}}
202+
{{- include "getValueFromSecret" (dict "Namespace" .Release.Namespace "Name" (include "common.names.fullname" .) "Length" 10 "Key" "admin-password") -}}
203+
{{- end -}}
204+
{{- end }}
205+
206+
{{/*
207+
Returns the available value for certain key in an existing secret (if it exists),
208+
otherwise it generates a random value.
209+
*/}}
210+
{{- define "getValueFromSecret" }}
211+
{{- $len := (default 16 .Length) | int -}}
212+
{{- $obj := (lookup "v1" "Secret" .Namespace .Name).data -}}
213+
{{- if $obj }}
214+
{{- index $obj .Key | b64dec -}}
215+
{{- else -}}
216+
{{- randAlphaNum $len -}}
217+
{{- end -}}
218+
{{- end }}
219+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "common.names.fullname" . }}-backup
5+
namespace: {{ include "common.names.namespace" . | quote }}
6+
labels: {{- include "common.labels.standard" . | nindent 4 }}
7+
{{- if .Values.commonLabels }}
8+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
9+
{{- end }}
10+
cluster-name: {{ template "patroni.fullname" . }}
11+
{{- if .Values.commonAnnotations }}
12+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
13+
{{- end }}
14+
data:
15+
backup.env: |-
16+
{{- include "common.tplvalues.render" ( dict "value" .Values.backupEnv "context" $ ) | nindent 4 }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if (include "patroni.createLogicalBackupCronJob" .) }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}-logicalbackup
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+
logicalbackup.sh: |-
17+
{{- include "common.tplvalues.render" ( dict "value" .Values.logicalbackupScript "context" $ ) | nindent 4 }}
18+
19+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if (include "patroni.createConfigmap" .) }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}-patroni
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+
pre_init.sh: |-
17+
{{- include "common.tplvalues.render" ( dict "value" .Values.preInitScript "context" $ ) | nindent 4 }}
18+
post_init.sh: |-
19+
{{- include "common.tplvalues.render" ( dict "value" .Values.postInitScript "context" $ ) | nindent 4 }}
20+
{{- end -}}
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 -}}

0 commit comments

Comments
 (0)