From f123adcd00e955f6fca23c862394ce6f56820097 Mon Sep 17 00:00:00 2001 From: pieter Date: Sat, 7 Feb 2026 00:17:05 +0000 Subject: [PATCH] =?UTF-8?q?templates/configmap.yaml=20=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/configmap.yaml | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 templates/configmap.yaml diff --git a/templates/configmap.yaml b/templates/configmap.yaml new file mode 100644 index 0000000..00383ce --- /dev/null +++ b/templates/configmap.yaml @@ -0,0 +1,80 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "postgresql.fullname" . }}-config + labels: + {{- include "postgresql.labels" . | nindent 4 }} +data: + {{- if .Values.replication.enabled }} + primary-init.sh: | + #!/bin/bash + set -e + + # レプリケーションユーザーの作成 + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER {{ .Values.postgres.replicationUser }} WITH REPLICATION ENCRYPTED PASSWORD '${REPLICATION_PASSWORD}'; + EOSQL + + # pg_hba.confの設定 + echo "host replication {{ .Values.postgres.replicationUser }} 0.0.0.0/0 md5" >> ${PGDATA}/pg_hba.conf + + # postgresql.confの設定 + cat >> ${PGDATA}/postgresql.conf < ${BACKUP_FILE} + + # 古いバックアップの削除 + find ${BACKUP_DIR} -name "backup_*.sql.gz" -mtime +${RETENTION_DAYS} -delete + + echo "Backup completed: ${BACKUP_FILE}" + + # バックアップサイズの確認 + ls -lh ${BACKUP_FILE} + {{- end }} +