Skip to content

Commit 63afd8c

Browse files
authored
feat: create wal dir, dont use root (#123)
1 parent f9ee08c commit 63afd8c

5 files changed

Lines changed: 27 additions & 9 deletions

File tree

Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v1
22
name: pgdog
3-
version: v0.71
4-
appVersion: "0.1.47"
3+
version: v0.72
4+
appVersion: "0.1.50"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ statefulSet:
129129
```
130130

131131
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.
132+
and mounts it at `/var/lib/pgdog`. Before PgDog starts, an init container creates
133+
`/var/lib/pgdog/wal` on the volume. The generated PgDog configuration sets
134+
`two_phase_commit_wal_dir` to that directory automatically. An explicit
135+
`twoPhaseCommitWalDir` value still takes precedence.
135136

136137
The claims use the cluster's default `StorageClass`. Ensure one is configured
137138
for dynamic provisioning before enabling `walPvc`. This option has no effect

templates/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ data:
152152
{{- if hasKey .Values "twoPhaseCommitWalDir" }}
153153
two_phase_commit_wal_dir = {{ .Values.twoPhaseCommitWalDir | quote }}
154154
{{- else if and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled }}
155-
two_phase_commit_wal_dir = "/var/lib/pgdog"
155+
two_phase_commit_wal_dir = "/var/lib/pgdog/wal"
156156
{{- end }}
157157
{{- if hasKey .Values "twoPhaseCommitWalSegmentSize" }}
158158
two_phase_commit_wal_segment_size = {{ include "pgdog.intval" .Values.twoPhaseCommitWalSegmentSize }}

templates/deployment.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,26 @@ spec:
5252
{{- else }}
5353
terminationGracePeriodSeconds: {{ add (div (default 60000 .Values.shutdownTimeout | int64) 1000) 5 }}
5454
{{- end }}
55-
{{- with .Values.extraInitContainers }}
55+
{{- if or (and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled) .Values.extraInitContainers }}
5656
initContainers:
57+
{{- if and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled }}
58+
- name: create-wal-directory
59+
{{- if .Values.image.name }}
60+
image: {{ .Values.image.name }}
61+
{{- else if .Values.image.digest }}
62+
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
63+
{{- else }}
64+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
65+
{{- end }}
66+
imagePullPolicy: {{ .Values.image.pullPolicy }}
67+
command: ["mkdir", "-p", "/var/lib/pgdog/wal"]
68+
volumeMounts:
69+
- name: wal
70+
mountPath: /var/lib/pgdog
71+
{{- end }}
72+
{{- with .Values.extraInitContainers }}
5773
{{- toYaml . | nindent 8 }}
74+
{{- end }}
5875
{{- end }}
5976
{{- with .Values.imagePullSecrets }}
6077
imagePullSecrets:

values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ statefulSet:
9090
# enabled switches from Deployment to StatefulSet
9191
enabled: false
9292
# 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.
93+
# The volume is mounted at /var/lib/pgdog. An init container creates the
94+
# /var/lib/pgdog/wal directory, which is used by twoPhaseCommitWalDir.
9595
walPvc:
9696
enabled: false
9797
size: 1Gi

0 commit comments

Comments
 (0)