diff --git a/chart/templates/postgres-cluster.yaml b/chart/templates/postgres-cluster.yaml index d31bfe4..66c6ae9 100644 --- a/chart/templates/postgres-cluster.yaml +++ b/chart/templates/postgres-cluster.yaml @@ -35,6 +35,17 @@ spec: initdb: database: {{ .Values.postgres.database }} owner: {{ .Values.postgres.owner }} + {{- with .Values.postgres.locale }} + # initdb-only: collation and ctype are fixed when the database is created. + # Changing them on a running cluster means a new cluster and a restore. + encoding: {{ .encoding | default "UTF8" }} + {{- with .collate }} + localeCollate: {{ . }} + {{- end }} + {{- with .ctype }} + localeCType: {{ . }} + {{- end }} + {{- end }} {{- if .Values.postgres.allowCreateDatabase }} # Development only. pytest-django creates and drops its own test database on # every run, which the bootstrap owner role cannot do by default. CNPG diff --git a/chart/values.yaml b/chart/values.yaml index 3337da0..10c12b4 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -145,6 +145,12 @@ postgres: image: ghcr.io/cloudnative-pg/postgresql:17 database: typelearn owner: typelearn + # Collation/ctype for the initial database, e.g. en_US.UTF-8. Empty keeps + # CNPG's default (C). Only read at bootstrap; it cannot be changed in place. + locale: {} + # encoding: UTF8 + # collate: en_US.UTF-8 + # ctype: en_US.UTF-8 storage: size: 1Gi # Empty uses the cluster's default StorageClass.