feat(infra): forte-drop in-cluster postgres + nightly backup (prod) #17
Reference in New Issue
Block a user
Delete Branch "feat/forte-drop-infra"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
In-cluster Postgres + nightly backups for forte-drop in upc-dev. PROD setup.
What changed
forte-drop-postgresql— Postgres 16 StatefulSet, 5Gi PVC onupcloud-block-storage-maxiops,POSTGRES_DB=drops, creds fromforte-drop-pg-credsSealedSecret. No securityContext (postgres image needs root to chown a fresh PVC, then drops to its own user via gosu).forte-drop-pg-backupCronJob — nightly 02:00 UTC:pg_dump | gzip→s3://drops/_pgbackups/(collision-proof prefix), 30-day retention. initContainer (pg_dump) + container (mc upload) sharing emptyDir. Reusesforte-drop-secretsS3 creds.argocd.argoproj.io/sync-options: Prune=false,Delete=falseon the volumeClaimTemplate.forte-drop-minio/deleted; object storage is UpCloud-managed.forte-dropcreated viaCreateNamespace=true(owned explicitly by the apps overlay's namespace.yaml, see the forte-drop-apps PR).Depends on
forte-drop-secretsSecret (S3 creds for the backup CronJob) — sealed in the forte-drop-apps PR. The CronJob's first run no-ops until that lands; self-heals.Test plan
kubectl kustomizecleankubectl -n forte-drop get pods→ postgresql-0 Runnings3://drops/_pgbackups/🤖 Generated with Claude Code
Two new ArgoCD Applications: - forte-drop-postgresql: in-cluster Postgres 16 StatefulSet, 5Gi PVC, POSTGRES_DB=drops, creds from forte-drop-pg-creds SealedSecret. - forte-drop-minio: in-cluster MinIO StatefulSet, 20Gi PVC, bootstrap Job creates the 'drops' bucket post-sync, creds from forte-drop-minio-creds SealedSecret. Both live in namespace 'forte-drop'. Mirrors the Vaultwarden pattern. Sealed secrets are added in a follow-up commit by the maintainer: kubeseal --fetch-cert > pub.pem kubeseal --cert pub.pem --format yaml < private/forte-drop-pg-creds.yaml > \ infra/overlays/upc-dev/forte-drop-postgresql/resources/forte-drop-pg-creds-sealed.yaml kubeseal --cert pub.pem --format yaml < private/forte-drop-minio-creds.yaml > \ infra/overlays/upc-dev/forte-drop-minio/resources/forte-drop-minio-creds-sealed.yamlInline review
@@ -0,0 +20,4 @@project: defaultsource:repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.gitSSH Git URL exposes the internal Git server hostname and port which may be considered sensitive infrastructure information.
#ai-review-inline
Inline review
@@ -0,0 +1,4 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- forte-drop-minio.yamlThe referenced resource file 'forte-drop-minio.yaml' should exist in the same directory for this Kustomization to work properly.
#ai-review-inline
Inline review
@@ -0,0 +1,4 @@apiVersion: kustomize.config.k8s.io/v1beta1Missing namespace field in Kustomization which is required for proper resource scoping.
#ai-review-inline
Inline review
@@ -0,0 +15,4 @@project: defaultsource:repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.gitUsing SSH Git URL may cause access issues in CI/CD pipelines; consider using HTTPS with token authentication.
#ai-review-inline
Inline review
@@ -0,0 +15,4 @@project: defaultsource:repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.gitUsing SSH Git URL may cause access issues in CI/CD pipelines; consider using HTTPS with token authentication.
#ai-review-inline
Inline review
@@ -0,0 +16,4 @@source:repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.gittargetRevision: HEADUsing HEAD as targetRevision can lead to unpredictable deployments; pin to a specific branch or tag.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1Remove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:Remove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- minio.yamlRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +2,4 @@kind: Kustomizationresources:- minio.yaml- forte-drop-minio-creds-sealed.yamlRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
Inline review
Inline review
@@ -0,0 +16,4 @@source:repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.gittargetRevision: HEADUsing HEAD as targetRevision can lead to unpredictable deployments; pin to a specific branch or tag.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1Remove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:Remove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- minio.yamlRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +2,4 @@kind: Kustomizationresources:- minio.yaml- forte-drop-minio-creds-sealed.yamlRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
Inline review
@@ -0,0 +16,4 @@source:repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.gittargetRevision: HEADUsing HEAD as targetRevision can lead to unpredictable deployments; pin to a specific branch or tag.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1Remove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:Remove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- minio.yamlRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
@@ -0,0 +2,4 @@kind: Kustomizationresources:- minio.yaml- forte-drop-minio-creds-sealed.yamlRemove the '# added' comment as it's not necessary for production code.
#ai-review-inline
Inline review
Inline review
@@ -0,0 +45,4 @@spec:containers:- name: minioimage: quay.io/minio/minio:latestUsing ':latest' tag is discouraged as it can lead to unpredictable deployments; pin to a specific version.
#ai-review-inline
@@ -0,0 +121,4 @@restartPolicy: OnFailurecontainers:- name: mcimage: quay.io/minio/mc:latestUsing ':latest' tag is discouraged as it can lead to unpredictable deployments; pin to a specific version.
#ai-review-inline
@@ -0,0 +137,4 @@- sh- -c- |set -eShell script should include 'set -uo pipefail' for better error handling and safer execution.
#ai-review-inline
Inline review
@@ -0,0 +45,4 @@spec:containers:- name: minioimage: quay.io/minio/minio:latestUsing ':latest' tag is discouraged as it can lead to unpredictable deployments; pin to a specific version.
#ai-review-inline
@@ -0,0 +121,4 @@restartPolicy: OnFailurecontainers:- name: mcimage: quay.io/minio/mc:latestUsing ':latest' tag is discouraged as it can lead to unpredictable deployments; pin to a specific version.
#ai-review-inline
@@ -0,0 +137,4 @@- sh- -c- |set -eShell script should include 'set -uo pipefail' for better error handling and safer execution.
#ai-review-inline
Inline review
Inline review
@@ -0,0 +40,4 @@app.kubernetes.io/instance: forte-dropapp.kubernetes.io/component: databasespec:containers:Container is missing securityContext which should be set for security best practices.
#ai-review-inline
Inline review
@@ -0,0 +40,4 @@app.kubernetes.io/instance: forte-dropapp.kubernetes.io/component: databasespec:containers:Container is missing securityContext which should be set for security best practices.
#ai-review-inline
Inline review
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1Remove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:Remove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- postgresql.yamlRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +2,4 @@kind: Kustomizationresources:- postgresql.yaml- forte-drop-pg-creds-sealed.yamlRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +42,4 @@spec:containers:- name: postgresqlimage: postgres:16-alpineContainer image should use a pinned digest or exact tag instead of 'postgres:16-alpine' for better security and reproducibility.
#ai-review-inline
Inline review
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1Remove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:Remove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- postgresql.yamlRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +2,4 @@kind: Kustomizationresources:- postgresql.yaml- forte-drop-pg-creds-sealed.yamlRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +42,4 @@spec:containers:- name: postgresqlimage: postgres:16-alpineContainer image should use a pinned digest or exact tag instead of 'postgres:16-alpine' for better security and reproducibility.
#ai-review-inline
Inline review
Inline review
Inline review
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1Remove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:Remove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +1,5 @@apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- postgresql.yamlRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +2,4 @@kind: Kustomizationresources:- postgresql.yaml- forte-drop-pg-creds-sealed.yamlRemove inline comment '# added' as it appears to be temporary diff annotation.
#ai-review-inline
@@ -0,0 +42,4 @@spec:containers:- name: postgresqlimage: postgres:16-alpineContainer image should use a pinned digest or exact tag instead of 'postgres:16-alpine' for better security and reproducibility.
#ai-review-inline
This PR adds new ArgoCD applications to deploy PostgreSQL and MinIO services for a forte-drop application in the upc-dev environment.
What changed: Added ArgoCD application definitions and Kubernetes manifests for PostgreSQL database and MinIO object storage components of the forte-drop system.
Affected services/namespaces:
Infrastructure impact:
Security notes: Both applications reference sealed secrets (forte-drop-pg-creds, forte-drop-minio-creds) for database and MinIO credentials - requires verification that these sealed secrets exist and contain proper credentials before deployment.
#ai-review-summary
ai-review triage
Gått igjennom alle 13 inline comments. Fixes pushet i
69848e4.Accepted (4)
forte-drop-minio/resources/minio.yamlquay.io/minio/minio:RELEASE.2024-12-18T13-15-44Z(was:latest) — Renovate vil bumpeforte-drop-minio/resources/minio.yamlquay.io/minio/mc:RELEASE.2024-11-21T17-21-54Zforte-drop-minio/resources/minio.yamlbootstrapset -e→set -euo pipefailforte-drop-postgresql/resources/postgresql.yamlRejected (9 — false positives + convention)
16-alpinefølger major.minor floating som er fint for patch updates. Ekte pin = digest sha256;16.1-alpineer ikke ekte pin (1 floater fortsatt). Renovate bumper når 16.2 kommer.#sealed-secrets pushet tidligere (
416615a). PR klar for re-review når du har tid @danijel.simeunovicCodex review pass (P1+P2)
Kjørte gpt-5 codex review etter ai-review fixes. To ekte regresjoner funnet og fikset:
P1 — postgres securityContext breaker initdb (
47d1f1e)Ai-review pushet
runAsNonRoot: true, runAsUser: 999, runAsGroup: 999på postgres-containeren. Postgres official image's entrypoint må starte som root for å chowne en fresh/var/lib/postgresql/data, så drops den selv til postgres user (uid 70 i alpine) via gosu. Forced UID 999 fra k8s blokkerer chown → initdb feiler på fresh PVC.Fix: dropp securityContext. Matcher Vaultwarden-mønsteret. Bevisst valg dokumentert i kommentar over containeren.
P2 — Namespace ownership cascade-risk (
178bf8c)forte-drop-postgresql.yamldeklarerteNamespace/forte-dropsom managed resource. MinIO bor i samme namespace fra en separat Application. Hvis postgres app prunes/slettes → Argo prunes namespace → MinIO cascade-deletes.Fix: fjern Namespace resource fra postgres-applikasjonen. Begge apps har allerede
syncOptions: CreateNamespace=trueså ArgoCD lager namespacet ved første sync uten å eie det.Klart for re-review @danijel.simeunovic
Du trenger ikke bry deg med
.pemfiler når du brukerkubeseal.Du kan gjøre det slik:
.pemer praktisk hvis man ikke har tilgang til clusteret ved seal, men det har du jo.Jeg vil foretrekke å ha denne deployment i
apps, ikkeinfra. Det er bare en enkel flytt av alt, strukturen skal være samme.feat(infra): forte-drop postgres + minio for upc-devto feat(infra): forte-drop in-cluster postgres + nightly backup (prod)Takk! Begge tatt:
--controller-name --controller-namespace), ingen .pem.apps/base/forte-drop-postgresql/(samme struktur, bare flyttet). Hele forte-drop-deployen (postgres + web + mcp) er nå samlet underapps/i #18.Lukker denne — supersedet av #18.
Pull request closed