Skip to content

Commit 7592892

Browse files
[postgres]: Fix invalid data dir path on postgres 18 (CloudPirates-io#165)
* [postgres]: Fix invalid data dir path on postgres 18 * Update CHANGELOG.md Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent f1bb75e commit 7592892

File tree

5 files changed

+51
-12
lines changed

5 files changed

+51
-12
lines changed

charts/postgres/CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3-
## 0.5.4 (2025-09-26)
3+
## 0.6.0 (2025-09-26)
44

5-
* [postgres] chore(deps): update docker.io/postgres:17.6 Docker digest to 0b6428e ([#161](https://github.com/CloudPirates-io/helm-charts/pull/161))
5+
* [postgres]: Fix invalid data dir path on postgres 18 ([#165](https://github.com/CloudPirates-io/helm-charts/pull/165))
6+
7+
## <small>0.5.4 (2025-09-26)</small>
8+
9+
* chore(deps): update docker.io/postgres:17.6 Docker digest to 0b6428e (#161) ([1946296](https://github.com/CloudPirates-io/helm-charts/commit/1946296)), closes [#161](https://github.com/CloudPirates-io/helm-charts/issues/161)
610

711
## <small>0.5.3 (2025-09-25)</small>
812

charts/postgres/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: postgres
33
description: The World's Most Advanced Open Source Relational Database
44
type: application
5-
version: 0.5.4
6-
appVersion: "17.6"
5+
version: 0.6.0
6+
appVersion: "18.0"
77
keywords:
88
- postgres
99
- postgresql

charts/postgres/templates/_helpers.tpl

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ Return PostgreSQL initialization scripts ConfigMap name
106106
{{- end -}}
107107
{{- end -}}
108108

109-
{{/*
110-
Return PostgreSQL data directory
111-
*/}}
112-
{{- define "postgres.dataDir" -}}
113-
{{- printf "/var/lib/postgresql/data" -}}
114-
{{- end }}
115109

116110
{{/*
117111
Return PostgreSQL config directory
@@ -169,4 +163,45 @@ Create the name of the service account to use
169163

170164
{{- define "postgres.custom-user-configname" -}}
171165
{{- printf "%s-custom-user-credentials" (include "postgres.fullname" .) -}}
166+
{{- end }}
167+
168+
{{/*
169+
Extract PostgreSQL major version from image tag
170+
*/}}
171+
{{- define "postgres.majorVersion" -}}
172+
{{- $tag := .Values.image.tag -}}
173+
{{- if contains "@" $tag -}}
174+
{{- $tag = (split "@" $tag)._0 -}}
175+
{{- end -}}
176+
{{- if contains "." $tag -}}
177+
{{- (split "." $tag)._0 -}}
178+
{{- else -}}
179+
{{- $tag -}}
180+
{{- end -}}
181+
{{- end }}
182+
183+
{{/*
184+
Return PostgreSQL data directory based on major version
185+
For PostgreSQL 18+, use version-specific path; for older versions use traditional path
186+
*/}}
187+
{{- define "postgres.dataDir" -}}
188+
{{- $majorVersion := include "postgres.majorVersion" . | int -}}
189+
{{- if ge $majorVersion 18 -}}
190+
{{- printf "/var/lib/postgresql" -}}
191+
{{- else -}}
192+
{{- printf "/var/lib/postgresql/data" -}}
193+
{{- end -}}
194+
{{- end }}
195+
196+
{{/*
197+
Return PGDATA path based on major version
198+
For PostgreSQL 18+, use version-specific PGDATA; for older versions use traditional PGDATA
199+
*/}}
200+
{{- define "postgres.pgdataPath" -}}
201+
{{- $majorVersion := include "postgres.majorVersion" . | int -}}
202+
{{- if ge $majorVersion 18 -}}
203+
{{- printf "/var/lib/postgresql/%d/docker" $majorVersion -}}
204+
{{- else -}}
205+
{{- printf "/var/lib/postgresql/data/pgdata" -}}
206+
{{- end -}}
172207
{{- end }}

charts/postgres/templates/statefulset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
- 'config_file={{ include "postgres.configDir" . }}/postgresql.conf'
4848
env:
4949
- name: PGDATA
50-
value: {{ include "postgres.dataDir" . }}/pgdata
50+
value: {{ include "postgres.pgdataPath" . }}
5151
{{- if .Values.initdb.args }}
5252
- name: POSTGRES_INITDB_ARGS
5353
value: {{ .Values.initdb.args | quote }}

charts/postgres/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ image:
2222
## @param image.repository PostgreSQL image repository
2323
repository: postgres
2424
## @param image.tag PostgreSQL image tag (immutable tags are recommended)
25-
tag: "17.6@sha256:0b6428e8c09651398137d2b3308a6ad87e73ac15fc38729891c16d942e947d3d"
25+
tag: "18.0@sha256:9685e09573f19eeb99d259547a1cb7a7a77cd15877f55f51e215ad06edf5c721"
2626
## @param image.imagePullPolicy PostgreSQL image pull policy
2727
imagePullPolicy: Always
2828

0 commit comments

Comments
 (0)