# cnpg-cluster 버전 갱신 가이드 이 차트는 **PaaSup 자체 제작**이다. 업스트림 차트를 내려받는 `cloudnative-pg` 와 달리 `helm pull` 로 갱신하지 않는다. 갱신 사유는 두 가지다. 1. PostgreSQL major 버전 상향 (예: 18 → 19) 2. CNPG operator 버전 상향으로 CRD 필드가 바뀐 경우 ## 1. git 작업 환경 구성 ```sh git clone https://github.com/paasup/dip-catalog.git cd dip-catalog git checkout -b update-cnpg-cluster/<신규버전> ``` ## 2. 신규 버전 디렉토리 생성 ```sh NEW=1.1.0 OLD=1.0.0 cd manifests/helm/cnpg-cluster cp -R "$OLD" "$NEW" # Chart.yaml 의 version / appVersion 갱신 ``` | 필드 | 의미 | | --- | --- | | `version` | 이 차트의 버전 (디렉토리명과 일치시킨다) | | `appVersion` | 배포되는 PostgreSQL 버전 | ## 3. CRD 스키마 대조 operator 를 올렸다면 `Cluster` / `Database` / `Pooler` / `ScheduledBackup` CRD 스키마가 바뀌었을 수 있다. 템플릿이 쓰는 필드가 아직 존재하는지 확인한다. ```sh # 템플릿이 참조하는 spec 필드 목록 확인 kubectl get crd clusters.postgresql.cnpg.io -o json | python3 -c " import json,sys d=json.load(sys.stdin) print(sorted(d['spec']['versions'][0]['schema']['openAPIV3Schema'] ['properties']['spec']['properties'].keys())) " kubectl get crd databases.postgresql.cnpg.io -o json | python3 -c " import json,sys d=json.load(sys.stdin) print(sorted(d['spec']['versions'][0]['schema']['openAPIV3Schema'] ['properties']['spec']['properties'].keys())) " ``` ## 4. 렌더링·검증 ```sh NEW=1.1.0 cd manifests/helm/cnpg-cluster/$NEW # 1) lint helm lint . -f custom-values.yaml # 2) 기본 경로 렌더링 helm template pg-cnpg . -f custom-values.yaml -n test >/dev/null && echo OK # 3) 옵션 경로(backup/pooler/scheduledBackup) 렌더링 — 기본값이 false 이므로 별도 확인 필요 helm template pg-cnpg . -f custom-values.yaml -n test \ --set backup.enabled=true \ --set backup.barmanObjectStore.destinationPath=s3://x/y \ --set backup.barmanObjectStore.s3Credentials.accessKeyId.name=s \ --set backup.barmanObjectStore.s3Credentials.secretAccessKey.name=s \ --set scheduledBackup.enabled=true \ --set pooler.enabled=true >/dev/null && echo "옵션 경로 OK" # 4) 실제 API 서버 + CNPG webhook 검증 (스키마 위반을 여기서 잡는다) helm template pg-dryrun . -f custom-values.yaml -n <기존ns> \ | kubectl apply --dry-run=server -f - ``` 4단계가 가장 중요하다. `helm template` 은 CRD 스키마를 검사하지 않으므로 렌더링이 통과해도 실제 apply 에서 거부될 수 있다. ## 5. 렌더링 결과 비교 ```sh helm template pg . "$OLD" -f "$OLD/custom-values.yaml" -n test > /tmp/old.yaml 2>/dev/null || \ helm template pg "$OLD" -f "$OLD/custom-values.yaml" -n test > /tmp/old.yaml helm template pg "$NEW" -f "$NEW/custom-values.yaml" -n test > /tmp/new.yaml diff -u /tmp/old.yaml /tmp/new.yaml ``` ## 6. 배포 검증 개발 클러스터에 실제 배포해 `doc/charts/cnpg/deploy-test.md` 의 검증 항목을 재실행한다. 최소 통과 기준: 1. `readyInstances = instances`, `phase = Cluster in healthy state` 2. `-rw` / `-ro` 서비스 라우팅 분리 (`pg_is_in_recovery()` 가 `f` / `t`) 3. `-ro` 로 쓰기 시도 시 `read-only transaction` 오류 4. `databases[].extensions` 가 primary·전체 replica 에 모두 생성됨 5. primary Pod 삭제 → failover 후 쓰기 복구, failover 전후 데이터 보존 6. `postgresql.parameters` 가 `SHOW` 로 실제 반영 확인 ### PostgreSQL major 버전 상향 시 추가 확인 - 확장 호환성: `pgaudit`, `pg_stat_statements` 의 신규 major 대응 버전 존재 여부 - `postgresql.parameters` 중 제거·개명된 GUC 가 있는지 - major 업그레이드는 in-place 가 아니다. CNPG 는 논리 복제(`import`) 또는 새 클러스터 생성 후 데이터 이관 방식을 쓴다. `imageName` 만 바꾸면 기동에 실패한다. ## 7. 문서 갱신 | 파일 | 갱신 내용 | | --- | --- | | `CUSTOM-README.md` | 차트/PostgreSQL 버전, 변경된 values 키, operator 호환 버전 | | `BUILD-README.md` | 이 문서의 절차에 변경이 있으면 반영 | | `dip-values.yaml` / `dip-*-quotas.yaml` | 파라미터 이름이 바뀌었으면 반영 | | `doc/charts/cnpg/deploy-test.md` | 신규 버전 검증 결과 추가 | ## 8. PR ```sh git add manifests/helm/cnpg-cluster/<신규버전> doc/ git commit -m "cnpg-cluster <신규버전> 추가 (PostgreSQL <버전>)" git push -u origin update-cnpg-cluster/<신규버전> ``` `helm-catalog-sbom` 워크플로가 PR 에서 변경 차트의 SBOM·취약점 스캔을 수행한다.