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 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/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 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 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