From 29d6aa806dd37b2db3a6ca5b7bfa2b9950818762 Mon Sep 17 00:00:00 2001 From: justgithubaccount Date: Sat, 6 Dec 2025 12:29:45 +0300 Subject: [PATCH 1/4] feat(infra): add Crunchy Data PostgreSQL Operator (PGO) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../database/pgo/base/application.yaml | 29 +++++++++++++++++++ .../database/pgo/base/kustomization.yaml | 4 +++ 2 files changed, 33 insertions(+) create mode 100644 platform/infrastructure/database/pgo/base/application.yaml create mode 100644 platform/infrastructure/database/pgo/base/kustomization.yaml diff --git a/platform/infrastructure/database/pgo/base/application.yaml b/platform/infrastructure/database/pgo/base/application.yaml new file mode 100644 index 0000000..efa2754 --- /dev/null +++ b/platform/infrastructure/database/pgo/base/application.yaml @@ -0,0 +1,29 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: pgo-operator + namespace: argocd + annotations: + argocd.argoproj.io/sync-wave: "1" +spec: + project: default + source: + repoURL: registry.developers.crunchydata.com/crunchydata + chart: pgo + targetRevision: "5.7.4" + helm: + values: | + singleNamespace: false + destination: + name: CLUSTER + namespace: postgres-operator + syncPolicy: + automated: + allowEmpty: true + selfHeal: true + prune: true + syncOptions: + - Validate=true + - CreateNamespace=true + - PruneLast=true + - ServerSideApply=true diff --git a/platform/infrastructure/database/pgo/base/kustomization.yaml b/platform/infrastructure/database/pgo/base/kustomization.yaml new file mode 100644 index 0000000..977dcfe --- /dev/null +++ b/platform/infrastructure/database/pgo/base/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - application.yaml From 9d8399dd52352e896b3f65149a4fd2a9090a7676 Mon Sep 17 00:00:00 2001 From: justgithubaccount Date: Sat, 6 Dec 2025 12:29:56 +0300 Subject: [PATCH 2/4] feat(chat): add PostgresCluster for chat-api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../chat/overlays/dev/postgres-cluster.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tenants/product-team/apps/chat/overlays/dev/postgres-cluster.yaml diff --git a/tenants/product-team/apps/chat/overlays/dev/postgres-cluster.yaml b/tenants/product-team/apps/chat/overlays/dev/postgres-cluster.yaml new file mode 100644 index 0000000..6068866 --- /dev/null +++ b/tenants/product-team/apps/chat/overlays/dev/postgres-cluster.yaml @@ -0,0 +1,64 @@ +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: chat-db + namespace: chat-api +spec: + postgresVersion: 16 + + instances: + - name: instance1 + replicas: 1 + dataVolumeClaimSpec: + storageClassName: longhorn + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + resources: + limits: + cpu: "2" + memory: 2Gi + requests: + cpu: "500m" + memory: 1Gi + + backups: + pgbackrest: + repos: + - name: repo1 + volume: + volumeClaimSpec: + storageClassName: longhorn + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + + patroni: + dynamicConfiguration: + postgresql: + parameters: + max_connections: "150" + shared_buffers: "512MB" + effective_cache_size: "1536MB" + maintenance_work_mem: "128MB" + checkpoint_completion_target: "0.9" + wal_buffers: "16MB" + default_statistics_target: "100" + random_page_cost: "1.1" + effective_io_concurrency: "200" + work_mem: "3495kB" + min_wal_size: "1GB" + max_wal_size: "4GB" + max_worker_processes: "2" + max_parallel_workers_per_gather: "1" + max_parallel_workers: "2" + max_parallel_maintenance_workers: "1" + + users: + - name: chatapi + databases: + - chat From 816a0bd0f5742c4339ffe4431776661feb6554b5 Mon Sep 17 00:00:00 2001 From: justgithubaccount Date: Sat, 6 Dec 2025 12:30:08 +0300 Subject: [PATCH 3/4] feat(chat): configure chat-api to use PGO PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- clusters/dev/kustomization.yaml | 2 ++ .../apps/chat/overlays/dev/kustomization.yaml | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clusters/dev/kustomization.yaml b/clusters/dev/kustomization.yaml index 656f695..1aaba3b 100644 --- a/clusters/dev/kustomization.yaml +++ b/clusters/dev/kustomization.yaml @@ -16,6 +16,8 @@ resources: - ../../platform/infrastructure/networking/external-dns/base # Storage - ../../platform/infrastructure/storage/longhorn/base + # Database + - ../../platform/infrastructure/database/pgo/base # AI Platform - ../../platform/infrastructure/ai-platform/open-webui/base # Observability diff --git a/tenants/product-team/apps/chat/overlays/dev/kustomization.yaml b/tenants/product-team/apps/chat/overlays/dev/kustomization.yaml index fa5a8e3..52777a4 100644 --- a/tenants/product-team/apps/chat/overlays/dev/kustomization.yaml +++ b/tenants/product-team/apps/chat/overlays/dev/kustomization.yaml @@ -3,7 +3,7 @@ kind: Kustomization resources: - ../../base - - postgree-secrets.yaml + - postgres-cluster.yaml - openrouter-secrets.yaml - github-secrets.yaml @@ -35,3 +35,10 @@ patches: ingress: enabled: true host: chat-dev.syncjob.ru + postgresSecretRefName: "" + extraEnv: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: chat-db-pguser-chatapi + key: uri From e2cd2707c58d8d1c339d3303c5fd753514eb19c6 Mon Sep 17 00:00:00 2001 From: justgithubaccount Date: Sat, 6 Dec 2025 12:34:18 +0300 Subject: [PATCH 4/4] ci: skip PostgresCluster in kubeconform validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index f1a6c87..8ac511c 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -38,7 +38,7 @@ jobs: - name: Kubeconform validation run: | kubeconform -summary -strict \ - -skip Application,ApplicationSet,Certificate,ClusterIssuer,SealedSecret \ + -skip Application,ApplicationSet,Certificate,ClusterIssuer,SealedSecret,PostgresCluster \ rendered.yaml - name: OPA policy check