Files
service-catalog/manifests/helm/cnpg-cluster/1.1.0/templates/cluster.yaml
T
wbsong111 b9e94a054a cnpg-cluster 1.1.0 — postInitApplicationSQLRefs 노출
앱별 부트스트랩 SQL 을 ConfigMap/Secret 참조로 실행할 수 있게 한다. CNPG CRD 에는
이미 있는 필드(operator 0.29.0/CRD 확인됨)인데 차트가 렌더하지 않아 values 로 쓸 수
없었다.

용도: 스키마 덤프처럼 큰 SQL 을 values 에 인라인하지 않고 ConfigMap 으로 넘기는 경우.
postInitApplicationSQL(인라인)과 시점·권한이 동일(클러스터 생성 직후 1회, 앱 DB 안에서
superuser) 하고 SQL 출처만 다르다. 1회성이라 비멱등 SQL(CREATE TABLE 등)을 그대로
넣어도 재실행되지 않는다.

- values.yaml: bootstrap.initdb.postInitApplicationSQLRefs 추가(configMapRefs/secretRefs,
  기본 빈 배열)
- templates/cluster.yaml: 값이 있을 때만 렌더(있으면 렌더, 없으면 필드 자체가 안 나옴 —
  기존 클러스터에 영향 없음을 렌더 테스트로 확인)
- CUSTOM-README.md: postInitApplicationSQL 과의 차이·참조 처리 순서(Secret 전체 →
  ConfigMap 전체) 문서화

카탈로그 관례 파일(BUILD-README·CUSTOM-README 본문 대부분·dip-*.yaml·custom-values.yaml)은
1.0.0 에서 그대로 승계했다(diff 로 확인).

검증: 빈 값일 때 필드 미노출, configMapRefs 지정 시 정상 렌더, 기존 1.0.0
custom-values.yaml 로 1.1.0 렌더해도 문제없음(하위 호환) 확인.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 11:24:23 +09:00

136 lines
4.4 KiB
YAML

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: {{ include "cnpg-cluster.fullname" . }}
namespace: {{ include "cnpg-cluster.namespace" . }}
labels:
{{- include "cnpg-cluster.labels" . | nindent 4 }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.extraAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
instances: {{ .Values.instances }}
imageName: {{ include "cnpg-cluster.image" . }}
primaryUpdateStrategy: {{ .Values.primaryUpdateStrategy }}
primaryUpdateMethod: {{ .Values.primaryUpdateMethod }}
enableSuperuserAccess: {{ .Values.enableSuperuserAccess }}
postgresql:
{{- with .Values.postgresql.parameters }}
parameters:
{{- range $k, $v := . }}
{{ $k }}: {{ $v | quote }}
{{- end }}
{{- end }}
{{- with .Values.postgresql.sharedPreloadLibraries }}
shared_preload_libraries:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.postgresql.pg_hba }}
pg_hba:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.postgresql.synchronous }}
synchronous:
{{- toYaml . | nindent 6 }}
{{- end }}
bootstrap:
initdb:
database: {{ .Values.bootstrap.initdb.database }}
owner: {{ .Values.bootstrap.initdb.owner }}
{{- with .Values.bootstrap.initdb.secretName }}
secret:
name: {{ . }}
{{- end }}
{{- with .Values.bootstrap.initdb.encoding }}
encoding: {{ . }}
{{- end }}
{{- with .Values.bootstrap.initdb.localeCollate }}
localeCollate: {{ . }}
{{- end }}
{{- with .Values.bootstrap.initdb.localeCType }}
localeCType: {{ . }}
{{- end }}
{{- with .Values.bootstrap.initdb.postInitApplicationSQL }}
postInitApplicationSQL:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bootstrap.initdb.postInitApplicationSQLRefs }}
{{- if or .configMapRefs .secretRefs }}
postInitApplicationSQLRefs:
{{- with .secretRefs }}
secretRefs:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .configMapRefs }}
configMapRefs:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
storage:
size: {{ .Values.storage.size }}
{{- with .Values.storage.storageClass }}
storageClass: {{ . }}
{{- end }}
{{- if .Values.walStorage.enabled }}
walStorage:
size: {{ .Values.walStorage.size }}
{{- with .Values.walStorage.storageClass }}
storageClass: {{ . }}
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 4 }}
affinity:
enablePodAntiAffinity: {{ .Values.affinity.enablePodAntiAffinity }}
podAntiAffinityType: {{ .Values.affinity.podAntiAffinityType }}
topologyKey: {{ .Values.affinity.topologyKey }}
{{- with .Values.affinity.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.affinity.tolerations }}
tolerations:
{{- toYaml . | nindent 6 }}
{{- end }}
monitoring:
enablePodMonitor: {{ .Values.monitoring.enablePodMonitor }}
{{- with .Values.monitoring.customQueriesConfigMap }}
customQueriesConfigMap:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- if .Values.backup.enabled }}
backup:
retentionPolicy: {{ .Values.backup.retentionPolicy }}
barmanObjectStore:
destinationPath: {{ required "backup.enabled=true 이면 backup.barmanObjectStore.destinationPath 가 필요하다" .Values.backup.barmanObjectStore.destinationPath }}
{{- with .Values.backup.barmanObjectStore.endpointURL }}
endpointURL: {{ . }}
{{- end }}
s3Credentials:
accessKeyId:
name: {{ required "backup.enabled=true 이면 s3Credentials.accessKeyId.name 이 필요하다" .Values.backup.barmanObjectStore.s3Credentials.accessKeyId.name }}
key: {{ .Values.backup.barmanObjectStore.s3Credentials.accessKeyId.key }}
secretAccessKey:
name: {{ required "backup.enabled=true 이면 s3Credentials.secretAccessKey.name 이 필요하다" .Values.backup.barmanObjectStore.s3Credentials.secretAccessKey.name }}
key: {{ .Values.backup.barmanObjectStore.s3Credentials.secretAccessKey.key }}
wal:
{{- toYaml .Values.backup.barmanObjectStore.wal | nindent 8 }}
data:
{{- toYaml .Values.backup.barmanObjectStore.data | nindent 8 }}
{{- end }}