apiVersion: apps/v1 kind: StatefulSet metadata: name: paperclip-postgres namespace: paperclip spec: serviceName: paperclip-postgres replicas: 1 selector: matchLabels: app: paperclip-postgres template: metadata: labels: app: paperclip-postgres spec: containers: - name: postgres image: postgres:16-alpine imagePullPolicy: IfNotPresent ports: - name: postgres containerPort: 5432 protocol: TCP env: - name: POSTGRES_DB value: paperclip - name: POSTGRES_USER value: paperclip - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: paperclip-secrets key: POSTGRES_PASSWORD resources: requests: cpu: 250m memory: 512Mi limits: cpu: 1000m memory: 2Gi volumeMounts: - name: postgres-data mountPath: /var/lib/postgresql/data subPath: pgdata livenessProbe: exec: command: - /bin/sh - -c - pg_isready -U paperclip initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 3 readinessProbe: exec: command: - /bin/sh - -c - pg_isready -U paperclip initialDelaySeconds: 5 periodSeconds: 5 timeoutSeconds: 3 successThreshold: 1 failureThreshold: 3 volumeClaimTemplates: - metadata: name: postgres-data annotations: # Prevent Argo CD from deleting this PVC to avoid data loss argocd.argoproj.io/sync-options: Delete=false spec: accessModes: - ReadWriteOnce storageClassName: local-path resources: requests: storage: 20Gi