From d47d57aa14789c6750e5349b026093c9a578df57 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 11 Nov 2026 23:39:12 +0900 Subject: [PATCH] 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. --- scripts/validate/render-phase1.sh | 4 ++++ services/platform-postgres/README.md | 13 ++++++++++--- services/platform-postgres/base/cluster.yaml | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/validate/render-phase1.sh b/scripts/validate/render-phase1.sh index 1292a45..6093bcc 100755 --- a/scripts/validate/render-phase1.sh +++ b/scripts/validate/render-phase1.sh @@ -402,6 +402,10 @@ fi fail "the Keycloak role must authenticate only to the Keycloak database" [[ "$(rg --count -- '^[[:space:]]*-[[:space:]]host all keycloak all reject[[:space:]]*$' "${render_dir}/platform-postgres.yaml" || true)" == "1" ]] || \ fail "the Keycloak role must be rejected from every other database" +[[ "$(rg --count -- '^[[:space:]]*-[[:space:]]host techlog techlog all scram-sha-256[[:space:]]*$' "${render_dir}/platform-postgres.yaml" || true)" == "1" ]] || \ + fail "the tech-log role must authenticate only to the tech-log database" +[[ "$(rg --count -- '^[[:space:]]*-[[:space:]]host all techlog all reject[[:space:]]*$' "${render_dir}/platform-postgres.yaml" || true)" == "1" ]] || \ + fail "the tech-log role must be rejected from every other database" rg --quiet '^kind: CustomResourceDefinition$' "${render_dir}/cnpg-operator.yaml" || \ diff --git a/services/platform-postgres/README.md b/services/platform-postgres/README.md index ebb0f2e..0293d15 100644 --- a/services/platform-postgres/README.md +++ b/services/platform-postgres/README.md @@ -21,9 +21,16 @@ platform-postgres-rw.platform-data.svc.cluster.local:5432 업그레이드한다. Cluster의 사용자 정의 `pg_hba` 규칙은 `gitea`가 `gitea` Database에만, -`keycloak`이 `keycloak` Database에만 인증하도록 허용한 뒤 각 Role의 다른 모든 -Database 접근을 거부한다. 이 규칙들은 CloudNativePG의 기본 fallback 인증 규칙보다 -앞에 배치된다. +`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 계약 diff --git a/services/platform-postgres/base/cluster.yaml b/services/platform-postgres/base/cluster.yaml index 070617d..c280342 100644 --- a/services/platform-postgres/base/cluster.yaml +++ b/services/platform-postgres/base/cluster.yaml @@ -24,6 +24,8 @@ spec: - host all gitea all reject - host keycloak keycloak all scram-sha-256 - host all keycloak all reject + - host techlog techlog all scram-sha-256 + - host all techlog all reject storage: size: 20Gi