# ========================================================= # Arcticnewone 可选生产数据库 - PostgreSQL StatefulSet # # 说明: # - 仅当生产环境没有可用的 PostgreSQL(如华为云 RDS)时才使用本文件 # - 建议优先使用云托管数据库(RDS),自带备份/高可用,运维成本更低 # - 数据保存在 PVC(8Gi 本地存储类),如需扩容请先调整 storage # - 部署后创建 Secret 提供连接信息(见 deploy/README.md) # ========================================================= apiVersion: v1 kind: Service metadata: name: arcticnewone-postgres namespace: arcticnewone labels: app: arcticnewone-postgres spec: clusterIP: None ports: - name: postgres port: 5432 targetPort: 5432 selector: app: arcticnewone-postgres --- apiVersion: apps/v1 kind: StatefulSet metadata: name: arcticnewone-postgres namespace: arcticnewone labels: app: arcticnewone-postgres spec: serviceName: arcticnewone-postgres replicas: 1 selector: matchLabels: app: arcticnewone-postgres template: metadata: labels: app: arcticnewone-postgres spec: containers: - name: postgres image: docker.m.daocloud.io/library/postgres:16-alpine ports: - name: postgres containerPort: 5432 env: - name: POSTGRES_DB value: "arcticnewone" - name: POSTGRES_USER value: "arcticnewone" - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: arcticnewone-secrets key: postgres-password volumeMounts: - name: data mountPath: /var/lib/postgresql/data resources: requests: cpu: 100m memory: 256Mi limits: cpu: 500m memory: 1Gi readinessProbe: exec: command: ["pg_isready", "-U", "arcticnewone", "-d", "arcticnewone"] initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: exec: command: ["pg_isready", "-U", "arcticnewone", "-d", "arcticnewone"] initialDelaySeconds: 15 periodSeconds: 20 volumeClaimTemplates: - metadata: name: data spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 8Gi