# PostgreSQL StatefulSet for HAPI # Provides production-ready PostgreSQL with persistent storage apiVersion: apps/v1 kind: StatefulSet metadata: name: postgres-statefulset labels: app: postgres spec: serviceName: postgres-service replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: securityContext: fsGroup: 999 containers: - name: postgres image: postgres:16.3 ports: - containerPort: 5432 name: postgres env: - name: POSTGRES_USER valueFrom: secretKeyRef: name: postgres-secrets key: username - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: postgres-secrets key: password - name: POSTGRES_DB value: ${POSTGRES_DB} - name: PGDATA value: /var/lib/postgresql/data/pgdata volumeMounts: - name: postgres-data mountPath: /var/lib/postgresql/data - name: postgres-config mountPath: /etc/postgresql/postgresql.conf subPath: postgresql.conf resources: requests: cpu: "500m" memory: "512Mi" limits: cpu: "1000m" memory: "1Gi" securityContext: runAsUser: 999 runAsNonRoot: true readinessProbe: exec: command: - pg_isready - -U - postgres initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: exec: command: - pg_isready - -U - postgres initialDelaySeconds: 15 periodSeconds: 20 volumes: - name: postgres-data persistentVolumeClaim: claimName: postgres-data - name: postgres-config configMap: name: postgres-config volumeClaimTemplates: - metadata: name: postgres-data spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 10Gi