Skip to content

Commit b977342

Browse files
feat: add Crunchy Data PostgreSQL Operator for chat-api (#9)
* feat(infra): add Crunchy Data PostgreSQL Operator (PGO) Add PGO operator as ArgoCD Application for managing PostgreSQL clusters in Kubernetes. Deployed to postgres-operator namespace with sync-wave 1. - Helm chart: registry.developers.crunchydata.com/crunchydata/pgo - Version: 5.7.4 - singleNamespace: false (manages all namespaces) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat(chat): add PostgresCluster for chat-api Create in-cluster PostgreSQL database for chat-api using PGO: - PostgreSQL 16 with optimized configuration - 10Gi data volume on Longhorn storage - 5Gi backup volume for pgBackRest - User: chatapi, Database: chat PostgreSQL tuning for 2GB RAM / 2 CPU: - max_connections: 150 - shared_buffers: 512MB - effective_cache_size: 1536MB - work_mem: 3495kB 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat(chat): configure chat-api to use PGO PostgreSQL - Add PGO operator to dev cluster kustomization - Update chat-api to use PGO-managed secret (chat-db-pguser-chatapi) - Map PGO secret 'uri' key to DATABASE_URL via extraEnv - Remove old postgree-secrets.yaml dependency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * ci: skip PostgresCluster in kubeconform validation PostgresCluster is a CRD from Crunchy Data PGO operator, kubeconform doesn't have schema for it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent e084269 commit b977342

File tree

6 files changed

+108
-2
lines changed

6 files changed

+108
-2
lines changed

.github/workflows/validate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Kubeconform validation
3939
run: |
4040
kubeconform -summary -strict \
41-
-skip Application,ApplicationSet,Certificate,ClusterIssuer,SealedSecret \
41+
-skip Application,ApplicationSet,Certificate,ClusterIssuer,SealedSecret,PostgresCluster \
4242
rendered.yaml
4343
4444
- name: OPA policy check

clusters/dev/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ resources:
1616
- ../../platform/infrastructure/networking/external-dns/base
1717
# Storage
1818
- ../../platform/infrastructure/storage/longhorn/base
19+
# Database
20+
- ../../platform/infrastructure/database/pgo/base
1921
# AI Platform
2022
- ../../platform/infrastructure/ai-platform/open-webui/base
2123
# Observability
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: pgo-operator
5+
namespace: argocd
6+
annotations:
7+
argocd.argoproj.io/sync-wave: "1"
8+
spec:
9+
project: default
10+
source:
11+
repoURL: registry.developers.crunchydata.com/crunchydata
12+
chart: pgo
13+
targetRevision: "5.7.4"
14+
helm:
15+
values: |
16+
singleNamespace: false
17+
destination:
18+
name: CLUSTER
19+
namespace: postgres-operator
20+
syncPolicy:
21+
automated:
22+
allowEmpty: true
23+
selfHeal: true
24+
prune: true
25+
syncOptions:
26+
- Validate=true
27+
- CreateNamespace=true
28+
- PruneLast=true
29+
- ServerSideApply=true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- application.yaml

tenants/product-team/apps/chat/overlays/dev/kustomization.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Kustomization
33

44
resources:
55
- ../../base
6-
- postgree-secrets.yaml
6+
- postgres-cluster.yaml
77
- openrouter-secrets.yaml
88
- github-secrets.yaml
99

@@ -35,3 +35,10 @@ patches:
3535
ingress:
3636
enabled: true
3737
host: chat-dev.syncjob.ru
38+
postgresSecretRefName: ""
39+
extraEnv:
40+
- name: DATABASE_URL
41+
valueFrom:
42+
secretKeyRef:
43+
name: chat-db-pguser-chatapi
44+
key: uri
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: chat-db
5+
namespace: chat-api
6+
spec:
7+
postgresVersion: 16
8+
9+
instances:
10+
- name: instance1
11+
replicas: 1
12+
dataVolumeClaimSpec:
13+
storageClassName: longhorn
14+
accessModes:
15+
- ReadWriteOnce
16+
resources:
17+
requests:
18+
storage: 10Gi
19+
resources:
20+
limits:
21+
cpu: "2"
22+
memory: 2Gi
23+
requests:
24+
cpu: "500m"
25+
memory: 1Gi
26+
27+
backups:
28+
pgbackrest:
29+
repos:
30+
- name: repo1
31+
volume:
32+
volumeClaimSpec:
33+
storageClassName: longhorn
34+
accessModes:
35+
- ReadWriteOnce
36+
resources:
37+
requests:
38+
storage: 5Gi
39+
40+
patroni:
41+
dynamicConfiguration:
42+
postgresql:
43+
parameters:
44+
max_connections: "150"
45+
shared_buffers: "512MB"
46+
effective_cache_size: "1536MB"
47+
maintenance_work_mem: "128MB"
48+
checkpoint_completion_target: "0.9"
49+
wal_buffers: "16MB"
50+
default_statistics_target: "100"
51+
random_page_cost: "1.1"
52+
effective_io_concurrency: "200"
53+
work_mem: "3495kB"
54+
min_wal_size: "1GB"
55+
max_wal_size: "4GB"
56+
max_worker_processes: "2"
57+
max_parallel_workers_per_gather: "1"
58+
max_parallel_workers: "2"
59+
max_parallel_maintenance_workers: "1"
60+
61+
users:
62+
- name: chatapi
63+
databases:
64+
- chat

0 commit comments

Comments
 (0)