Files
platform-core/services/platform-postgres/base/cluster.yaml
T
DongHyeonka 4551a2ece6 feat(platform-postgres): run the shared database as Guaranteed QoS
The one PostgreSQL instance holds the Gitea, Keycloak and tech-log
databases. It is Burstable at priority 0 with oom_score_adj 985, so
under memory pressure the kernel kills it before almost anything else,
and an eviction treats it like Grafana (k3s maturity review
2026-11-11, 7.2 items 2 and 3).

Set priorityClassName platform-critical (services/priority-classes)
and raise the requests to the existing limits, CPU 2 and memory 4Gi,
so the pod is Guaranteed and its oom_score_adj becomes -997. The
backup README now gives the restart, not pg_hba, as the reason to add
spec.backup with kubectl patch.

Risk: applying this changes the pod spec, so CloudNativePG restarts
the single instance and the three databases are down for that time.
It belongs in the k3s restart window. Node requests grow by 1.75 CPU
and 3.5Gi; peak use over the last 6 hours was 0.025 CPU and 195MB.

Verification: kubectl diff of the rendered build root against the live
cluster shows only priorityClassName, the two requests and the
DatabaseRole defaults that were already there; no pg_hba line differs.
render-phase1.sh passes.
2026-11-12 07:29:48 +09:00

54 lines
1.3 KiB
YAML

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: platform-postgres
labels:
app.kubernetes.io/name: platform-postgres
app.kubernetes.io/component: database
spec:
description: Shared platform PostgreSQL instance initialized for Gitea
instances: 1
imageName: ghcr.io/cloudnative-pg/postgresql:17.9-standard-trixie
bootstrap:
initdb:
dataChecksums: true
database: gitea
owner: gitea
secret:
name: gitea-db-credentials
postgresql:
pg_hba:
- host gitea gitea all scram-sha-256
- 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
managed:
services:
disabledDefaultServices:
- ro
- r
affinity:
enablePodAntiAffinity: false
# The DB is the last thing that should go when the node runs short.
# platform-critical comes from services/priority-classes. requests equal
# limits so the pod is Guaranteed QoS and its oom_score_adj drops from 985
# to -997 (k3s maturity review 2026-11-11, 7.2 items 2 and 3).
priorityClassName: platform-critical
resources:
requests:
cpu: "2"
memory: 4Gi
limits:
cpu: "2"
memory: 4Gi