2026-07-23 19:07:02 -07:00
|
|
|
# Forgejo PostgreSQL Database — CNPG Cluster CR
|
|
|
|
|
# This is the source of truth for Forgejo's database
|
|
|
|
|
# ArgoCD will adopt this (not recreate it)
|
|
|
|
|
---
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Namespace
|
|
|
|
|
metadata:
|
2026-07-23 20:54:02 -07:00
|
|
|
name: cicd
|
2026-07-23 19:07:02 -07:00
|
|
|
annotations:
|
|
|
|
|
argocd.argoproj.io/sync-options: Prune=false
|
|
|
|
|
---
|
|
|
|
|
apiVersion: postgresql.cnpg.io/v1
|
|
|
|
|
kind: Cluster
|
|
|
|
|
metadata:
|
|
|
|
|
name: forgejo-db
|
2026-07-23 20:54:02 -07:00
|
|
|
namespace: cicd
|
2026-07-23 19:07:02 -07:00
|
|
|
annotations:
|
|
|
|
|
argocd.argoproj.io/sync-options: Prune=false # Let ArgoCD adopt, don't delete
|
|
|
|
|
labels:
|
|
|
|
|
app: forgejo-db
|
|
|
|
|
layer: data
|
|
|
|
|
spec:
|
|
|
|
|
instances: 3 # HA configuration
|
|
|
|
|
|
|
|
|
|
imageName: ghcr.io/cloudnative-pg/postgresql:16.2
|
|
|
|
|
|
|
|
|
|
bootstrap:
|
|
|
|
|
initdb:
|
|
|
|
|
database: forgejo
|
|
|
|
|
owner: forgejo
|
|
|
|
|
encoding: UTF8
|
|
|
|
|
localeCollate: C
|
|
|
|
|
localeCType: C
|
|
|
|
|
|
|
|
|
|
enableSuperuserAccess: false
|
|
|
|
|
|
|
|
|
|
# Resource limits per best practices
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
memory: "4Gi"
|
|
|
|
|
cpu: "1"
|
|
|
|
|
limits:
|
|
|
|
|
memory: "8Gi"
|
|
|
|
|
cpu: "2"
|
|
|
|
|
|
|
|
|
|
postgresql:
|
|
|
|
|
parameters:
|
|
|
|
|
# Tuned for 4-8GB RAM
|
|
|
|
|
shared_buffers: "1GB"
|
|
|
|
|
effective_cache_size: "3GB"
|
|
|
|
|
maintenance_work_mem: "512MB"
|
|
|
|
|
work_mem: "64MB"
|
|
|
|
|
max_connections: "100"
|
|
|
|
|
max_parallel_workers: "2"
|
|
|
|
|
max_parallel_workers_per_gather: "1"
|
|
|
|
|
# WAL
|
|
|
|
|
wal_buffers: "16MB"
|
|
|
|
|
checkpoint_completion_target: "0.9"
|
|
|
|
|
min_wal_size: "512MB"
|
|
|
|
|
max_wal_size: "2GB"
|
|
|
|
|
# Logging
|
|
|
|
|
log_destination: "csvlog"
|
|
|
|
|
log_directory: "/controller/log"
|
|
|
|
|
log_filename: "postgres"
|
|
|
|
|
|
|
|
|
|
storage:
|
2026-08-18 15:08:03 -07:00
|
|
|
size: 25Gi
|
|
|
|
|
storageClass: longhorn-cnpg
|
2026-07-23 19:07:02 -07:00
|
|
|
|
|
|
|
|
monitoring:
|
|
|
|
|
enablePodMonitor: true
|
|
|
|
|
|
|
|
|
|
affinity:
|
2026-07-23 20:54:02 -07:00
|
|
|
# preferred (not required) so it can't deadlock if fewer than 3 nodes are
|
|
|
|
|
# schedulable; tolerations let CNPG pods land on control-plane nodes.
|
|
|
|
|
podAntiAffinityType: preferred
|
2026-07-23 19:07:02 -07:00
|
|
|
topologyKey: kubernetes.io/hostname
|
2026-07-23 20:54:02 -07:00
|
|
|
tolerations:
|
|
|
|
|
- key: node-role.kubernetes.io/control-plane
|
|
|
|
|
operator: Exists
|
|
|
|
|
effect: NoSchedule
|
2026-07-23 19:07:02 -07:00
|
|
|
---
|
|
|
|
|
# Forgejo Redis (cache, session, queue)
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Service
|
|
|
|
|
metadata:
|
|
|
|
|
name: forgejo-redis
|
2026-07-23 20:54:02 -07:00
|
|
|
namespace: cicd
|
2026-07-23 19:07:02 -07:00
|
|
|
annotations:
|
|
|
|
|
argocd.argoproj.io/sync-options: Prune=false
|
|
|
|
|
spec:
|
|
|
|
|
ports:
|
|
|
|
|
- port: 6379
|
|
|
|
|
targetPort: 6379
|
|
|
|
|
protocol: TCP
|
|
|
|
|
selector:
|
|
|
|
|
app: forgejo-redis
|
|
|
|
|
type: ClusterIP
|
|
|
|
|
---
|
|
|
|
|
apiVersion: apps/v1
|
|
|
|
|
kind: Deployment
|
|
|
|
|
metadata:
|
|
|
|
|
name: forgejo-redis
|
2026-07-23 20:54:02 -07:00
|
|
|
namespace: cicd
|
2026-07-23 19:07:02 -07:00
|
|
|
annotations:
|
|
|
|
|
argocd.argoproj.io/sync-options: Prune=false
|
|
|
|
|
spec:
|
|
|
|
|
replicas: 1
|
|
|
|
|
selector:
|
|
|
|
|
matchLabels:
|
|
|
|
|
app: forgejo-redis
|
|
|
|
|
template:
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app: forgejo-redis
|
|
|
|
|
spec:
|
2026-07-23 20:54:02 -07:00
|
|
|
tolerations:
|
|
|
|
|
- key: node-role.kubernetes.io/control-plane
|
|
|
|
|
operator: Exists
|
|
|
|
|
effect: NoSchedule
|
2026-07-23 19:07:02 -07:00
|
|
|
containers:
|
|
|
|
|
- name: redis
|
|
|
|
|
image: redis:7-alpine
|
|
|
|
|
ports:
|
|
|
|
|
- containerPort: 6379
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
cpu: 50m
|
|
|
|
|
memory: 64Mi
|
|
|
|
|
limits:
|
|
|
|
|
cpu: 200m
|
|
|
|
|
memory: 256Mi
|