Skip to content

Commit f9ee08c

Browse files
authored
feat: pvc for wal (#122)
* feat: pvc for wal * rename
1 parent 0cd9957 commit f9ee08c

6 files changed

Lines changed: 49 additions & 1 deletion

File tree

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v1
22
name: pgdog
3-
version: v0.70
3+
version: v0.71
44
appVersion: "0.1.47"

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ mirrors:
115115

116116
### High Availability
117117

118+
#### StatefulSet WAL storage
119+
120+
PgDog can persist its two-phase commit WAL when running as a StatefulSet.
121+
Enable `walPvc` and configure the requested capacity:
122+
123+
```yaml
124+
statefulSet:
125+
enabled: true
126+
walPvc:
127+
enabled: true
128+
size: 5Gi
129+
```
130+
131+
The StatefulSet creates one `ReadWriteOnce` persistent volume claim per replica
132+
and mounts it at `/var/lib/pgdog`. The generated PgDog configuration sets
133+
`two_phase_commit_wal_dir` to that mount point automatically. An explicit
134+
`twoPhaseCommitWalDir` value takes precedence.
135+
136+
The claims use the cluster's default `StorageClass`. Ensure one is configured
137+
for dynamic provisioning before enabling `walPvc`. This option has no effect
138+
when PgDog runs as a Deployment.
139+
118140
#### PodDisruptionBudget
119141

120142
Ensures minimum pod availability during voluntary disruptions

templates/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ data:
151151
{{- end }}
152152
{{- if hasKey .Values "twoPhaseCommitWalDir" }}
153153
two_phase_commit_wal_dir = {{ .Values.twoPhaseCommitWalDir | quote }}
154+
{{- else if and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled }}
155+
two_phase_commit_wal_dir = "/var/lib/pgdog"
154156
{{- end }}
155157
{{- if hasKey .Values "twoPhaseCommitWalSegmentSize" }}
156158
two_phase_commit_wal_segment_size = {{ include "pgdog.intval" .Values.twoPhaseCommitWalSegmentSize }}

templates/deployment.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ spec:
130130
mountPath: /etc/pgdog
131131
- name: users
132132
mountPath: /etc/secrets/pgdog
133+
{{- if and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled }}
134+
- name: wal
135+
mountPath: /var/lib/pgdog
136+
{{- end }}
133137
{{- if .Values.tlsGenerateSelfSignedCert }}
134138
- name: tls
135139
mountPath: /etc/pgdog-tls
@@ -254,3 +258,14 @@ spec:
254258
topologySpreadConstraints:
255259
{{- toYaml . | nindent 8 }}
256260
{{- end }}
261+
{{- if and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled }}
262+
volumeClaimTemplates:
263+
- metadata:
264+
name: wal
265+
spec:
266+
accessModes:
267+
- ReadWriteOnce
268+
resources:
269+
requests:
270+
storage: {{ .Values.statefulSet.walPvc.size | quote }}
271+
{{- end }}

test/values-statefulset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Test StatefulSet deployment mode
22
statefulSet:
33
enabled: true
4+
walPvc:
5+
enabled: true
6+
size: 5Gi

values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ replicas: 2
8989
statefulSet:
9090
# enabled switches from Deployment to StatefulSet
9191
enabled: false
92+
# walPvc creates one persistent volume claim per StatefulSet pod.
93+
# The volume is mounted at /var/lib/pgdog. When enabled,
94+
# twoPhaseCommitWalDir defaults to this mount point.
95+
walPvc:
96+
enabled: false
97+
size: 1Gi
9298

9399
# env allows setting custom environment variables on the pgdog container
94100
# Note: NODE_ID is automatically generated and cannot be overridden

0 commit comments

Comments
 (0)