Files
platform-core/services/platform-postgres
DongHyeonka 1c4ef9affd fix(platform-postgres): keep the tech-log pg_hba rules the cluster uses
The live platform-postgres Cluster has two pg_hba rules for the techlog
role that the repository does not declare. They were added outside the
repository for hyeonworks.com. Applying the current render would remove
them and the production backend could no longer reach its database.

Declare the same two rules, in the same position after the Keycloak
pair, and pin them with render invariants like the Gitea and Keycloak
pairs. The techlog DatabaseRole, Database, Secret and NetworkPolicies
stay outside this build root; where they belong is an owner decision
recorded in the 2026-11-11 maturity review.

Risk: none for the live cluster. The rendered Cluster now matches the
live object. A fresh install without the tech-log tenant gets two
rules for a role that does not exist, which PostgreSQL ignores.

Verification (desktop, Helm 3.19.4, Kustomize 5.8.1):
- render-phase1.sh with the old cluster.yaml and the new invariants
  fails: "the tech-log role must authenticate only to the tech-log
  database"; with the new cluster.yaml it passes.
- kubectl diff of the new render against the live cluster shows no
  Cluster change; only the pre-existing DatabaseRole default fields.
2026-11-11 23:39:58 +09:00
..

플랫폼 PostgreSQL — Phase 1 빌드 루트

이 Kustomization은 platform-data namespace에 Phase 1 CloudNativePG 기반 구성을 선언한다.

  • platform-postgres라는 Cluster 하나
  • Gitea용 DatabaseRole과 Database
  • CloudNativePG, 동일 Cluster 트래픽 및 Gitea만 허용하는 기본 ingress NetworkPolicy

PostgreSQL 17.9 인스턴스 하나로 시작하며 20 GiB Claim을 홈 서버의 정적 ssd-local-postgres-retain StorageClass에 바인딩한다. CloudNativePG에서는 필수 read/write Service만 유지한다.

platform-postgres-rw.platform-data.svc.cluster.local:5432

이미지 ghcr.io/cloudnative-pg/postgresql:17.9-standard-trixie는 공식 PostgreSQL 17 멀티 아키텍처 이미지로 고정되어 있다. 백업 및 복원 시험 후 의도적으로 태그를 업그레이드한다.

Cluster의 사용자 정의 pg_hba 규칙은 gitea가 gitea Database에만, keycloak이 keycloak Database에만, techlog가 techlog Database에만 인증하도록 허용한 뒤 각 Role의 다른 모든 Database 접근을 거부한다. 이 규칙들은 CloudNativePG의 기본 fallback 인증 규칙보다 앞에 배치된다.

techlog 규칙 쌍은 운영 tech-log(hyeonworks.com)가 쓰는 것으로, 클러스터에는 이 저장소 밖에서 먼저 들어갔다(2026-11-11 점검에서 확인). 이 규칙 쌍이 없는 렌더를 적용하면 운영 backend가 DB에 접속하지 못하므로 공통 Cluster에 둔다. techlog DatabaseRole·Database, platform-data/techlog-db-credentials와 tech-log용 NetworkPolicy는 아직 어느 저장소에도 없다. 둘 곳은 소유자가 정한다 (docs/reviews/2026-11-11-k3s-maturity-review.md 4절).

Phase 1 Secret 계약

Cluster를 생성하기 전에 platform-data에 gitea-db-credentials를 생성한다.

  • 유형: kubernetes.io/basic-auth
  • label: cnpg.io/reload: "true"
  • username: 정확히 gitea
  • password: Git 외부에서 제공하는 생성된 비밀번호

동일한 credential 값을 gitea namespace에 복사한다. initdb bootstrap은 최초 소유자와 Database를 만들 때 이 Secret을 사용하고 data checksum을 활성화한다. Gitea Role과 Database는 모두 retain 조정 정책을 사용한다.

Keycloak DatabaseRole, Database, Secret 참조 및 namespace 전용 ingress 허용은 이 Phase 1 빌드 루트에 의도적으로 포함하지 않았다. 공통 Cluster의 Keycloak HBA 허용·거부 규칙 쌍은 이곳에 유지하고, 독립적인 형제 빌드 루트 services/platform-postgres-keycloak이 Keycloak login Role, Database 및 namespace 전용 ingress를 추가한다. 2026-07-23 기준 이 Keycloak 확장은 실제 클러스터에 적용됐다. 두 빌드 루트가 분리돼 있으므로 platform-data/keycloak-db-credentials가 없어도 신규 Phase 1 baseline만은 배포할 수 있다.

의존성과 렌더링

  1. Phase 1 namespace를 생성한다.
  2. PostgreSQL SSD Local PV 기반 구성을 준비하고 적용한다.
  3. CloudNativePG Operator를 설치하고 준비될 때까지 기다린다.
  4. Gitea credential Secret 계약을 생성한다.
  5. 이 디렉터리를 렌더링하고 적용한다.
kubectl kustomize services/platform-postgres

렌더링 결과에는 Cluster 하나와 Gitea의 DatabaseRole 및 Database만 있어야 한다. Keycloak DatabaseRole, Database, Secret 참조 또는 Keycloak namespace ingress 허용은 없어야 하며, Keycloak용 HBA 정책만 존재해야 한다.

공식 참고 문서